﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Drawing.Drawing2D;
using System.Reflection;
using System.Windows.Forms;
using HML.Design;

namespace HML
{
    /// <summary>
    /// 手风琴菜单控件
    /// </summary>
    [Description("手风琴菜单控件")]
    [DefaultProperty("Nodes")]
    [DefaultEvent("SelectedNodeChanged")]
    [TypeConverter(typeof(SingleAccordionConverter))]
    [Designer(typeof(SingleAccordionDesigner))]
    [ToolboxItem(true)]
    [ToolboxBitmap(typeof(SingleAccordion), "Controls.SingleAccordion.SingleAccordion.bmp")]
    public class SingleAccordion : MainThreadAnimationControl, ISkinObject
    {
        #region 主题

        private SkinObjectXmlMetadata skinObjectXmlMetadata = null;
        /// <summary>
        /// 主题对象在主题文件信息
        /// </summary>
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public virtual SkinObjectXmlMetadata SkinObjectXmlMetadata
        {
            get
            {
                if (this.skinObjectXmlMetadata == null)
                    this.skinObjectXmlMetadata = new SkinObjectXmlMetadata(Assembly.GetAssembly(typeof(SingleAccordion)).GetName().Name, typeof(SingleAccordion).Name);

                return this.skinObjectXmlMetadata;
            }
        }

        private SkinController skinController = null;
        /// <summary>
        /// 主题控制器
        /// </summary>
        [Description("主题控制器")]
        [Category("杂项")]
        [PropertyOrder(-360)]
        [DefaultValue(null)]
        [RefreshProperties(RefreshProperties.All)]
        public virtual SkinController SkinController
        {
            get { return this.skinController; }
            set
            {
                if (this.skinController == value)
                    return;

                if (this.skinController != null)
                    this.skinController.RemoveSkinObject(this);

                this.skinController = value;

                if (this.skinController != null)
                    this.skinController.AddSkinObject(this);
            }
        }

        private SkinEnabledState skinEnabled= SkinEnabledState.Auto;
        /// <summary>
        /// 主题是否启用
        /// </summary>
        [Description("主题是否启用")]
        [Category("杂项")]
        [PropertyOrder(-300)]
        [DefaultValue(SkinEnabledState.Auto)]
        [RefreshProperties(RefreshProperties.All)]
        public virtual SkinEnabledState SkinEnabled
        {
            get { return this.skinEnabled; }
            set
            {
                if (this.skinEnabled == value)
                    return;

                this.skinEnabled = value;
                this.OnSkinChanged();
            }
        }

        private SkinStyle skinStyle = SkinStyle.Normal;
        /// <summary>
        /// 主题风格
        /// </summary>
        [Description("主题风格")]
        [Category("杂项")]
        [PropertyOrder(-260)]
        [DefaultValue(SkinStyle.Normal)]
        [RefreshProperties(RefreshProperties.All)]
        public virtual SkinStyle SkinStyle
        {
            get { return this.skinStyle; }
            set
            {
                if (this.skinStyle == value)
                    return;

                this.skinStyle = value;
                this.OnSkinChanged();
            }
        }

        private StyleAppearanceObject stateAppearance;
        /// <summary>
        /// 风格外观
        /// </summary>
        [Description("风格外观")]
        [Category("杂项")]
        [PropertyOrder(-200)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public StyleAppearanceObject StyleAppearance
        {
            get
            {
                if (this.stateAppearance == null)
                    this.stateAppearance = new StyleAppearanceObject(this, null);
                return this.stateAppearance;
            }
        }

        /// <summary>
        /// 主题已更改
        /// </summary>
        public virtual void OnSkinChanged()
        {
            SkinManager.SyncSkinValueToProperty(this);
            this.Invalidate();
        }

        private ISkinObject followSkinObject = null;
        /// <summary>
        /// 主题设置跟随指定主题对象（自己的设置不再生效，提供给代码使用）
        /// </summary>
        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [Localizable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public virtual ISkinObject FollowSkinObject
        {
            get { return this.followSkinObject; }
            set
            {
                if (this.followSkinObject == value)
                    return;

                this.followSkinObject = value;
                this.OnSkinChanged();
            }
        }

        public virtual bool GetSkinObjectSkinStateCore()
        {
            return SkinManager.GetSkinObjectSkinState(this.FollowSkinObject ?? this);
        }

        void ISkinObject.InitializeInvalidate()
        {
            this.InitializeElement();
            this.Invalidate();
        }

        void ISkinObject.Invalidate()
        {
            this.Invalidate();
        }

        #endregion

        #region 新增事件

        public delegate void SingleAccordionBackgroundDrawBeforeEventHandler(object sender, SingleAccordionBackgroundDrawBeforeEventArgs e);
        private static readonly object EventBackgroundDrawBefore = new object();
        /// <summary>
        /// 背景绘制前事件
        /// </summary>
        [Description("背景绘制前事件")]
        public event SingleAccordionBackgroundDrawBeforeEventHandler BackgroundDrawBefore
        {
            add { Events.AddHandler(EventBackgroundDrawBefore, value); }
            remove { Events.RemoveHandler(EventBackgroundDrawBefore, value); }
        }

        public delegate void SingleAccordionNodeDrawBeforeEventHandler(object sender, SingleAccordionNodeDrawBeforeEventArgs e);
        private static readonly object EventNodeDrawBefore = new object();
        /// <summary>
        /// 节点绘制前事件
        /// </summary>
        [Description("节点绘制前事件")]
        public event SingleAccordionNodeDrawBeforeEventHandler NodeDrawBefore
        {
            add { Events.AddHandler(EventNodeDrawBefore, value); }
            remove { Events.RemoveHandler(EventNodeDrawBefore, value); }
        }

        public delegate void SingleAccordionNodeDrawAfterEventHandler(object sender, SingleAccordionNodeDrawAfterEventArgs e);
        private static readonly object EventNodeDrawAfter = new object();
        /// <summary>
        /// 节点绘制后事件
        /// </summary>
        [Description("节点绘制后事件")]
        public event SingleAccordionNodeDrawAfterEventHandler NodeDrawAfter
        {
            add { Events.AddHandler(EventNodeDrawAfter, value); }
            remove { Events.RemoveHandler(EventNodeDrawAfter, value); }
        }

        public delegate void NodeClickEventHandler(object sender, SingleAccordionNodeEventArgs e);
        private static readonly object EventNodeClick = new object();
        /// <summary>
        /// 节点单击事件
        /// </summary>
        [Description("节点单击事件")]
        public event NodeClickEventHandler NodeClick
        {
            add { Events.AddHandler(EventNodeClick, value); }
            remove { Events.RemoveHandler(EventNodeClick, value); }
        }

        private static readonly object EventSelectedNodeChanged = new object();
        /// <summary>
        /// 选中节点更改事件
        /// </summary>
        [Description("选中节点更改事件")]
        public event EventHandler SelectedNodeChanged
        {
            add { Events.AddHandler(EventSelectedNodeChanged, value); }
            remove { Events.RemoveHandler(EventSelectedNodeChanged, value); }
        }

        #endregion

        #region 停用事件

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler PaddingChanged
        {
            add { base.PaddingChanged += value; }
            remove { base.PaddingChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler TabIndexChanged
        {
            add { base.TabIndexChanged += value; }
            remove { base.TabIndexChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler TabStopChanged
        {
            add { base.TabStopChanged += value; }
            remove { base.TabStopChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler BackgroundImageChanged
        {
            add { base.BackgroundImageChanged += value; }
            remove { base.BackgroundImageChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler BackgroundImageLayoutChanged
        {
            add { base.BackgroundImageLayoutChanged += value; }
            remove { base.BackgroundImageLayoutChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler TextChanged
        {
            add { base.TextChanged += value; }
            remove { base.TextChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler RightToLeftChanged
        {
            add { base.RightToLeftChanged += value; }
            remove { base.RightToLeftChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler ImeModeChanged
        {
            add { base.ImeModeChanged += value; }
            remove { base.ImeModeChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler BackColorChanged
        {
            add { base.BackColorChanged += value; }
            remove { base.BackColorChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler ForeColorChanged
        {
            add { base.ForeColorChanged += value; }
            remove { base.ForeColorChanged -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler Click
        {
            add { base.Click += value; }
            remove { base.Click -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event EventHandler DoubleClick
        {
            add { base.DoubleClick += value; }
            remove { base.DoubleClick -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event MouseEventHandler MouseClick
        {
            add { base.MouseClick += value; }
            remove { base.MouseClick -= value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new event MouseEventHandler MouseDoubleClick
        {
            add { base.MouseDoubleClick += value; }
            remove { base.MouseDoubleClick -= value; }
        }

        #endregion

        #region 新增属性

        private bool borderVisible = true;
        /// <summary>
        ///是否显示边框
        /// </summary>
        [Description("是否显示边框")]
        [Category("杂项")]
        [PropertyOrder(-198)]
        [DefaultValue(true)]
        public bool BorderVisible
        {
            get { return this.borderVisible; }
            set
            {
                if (this.borderVisible == value)
                    return;

                this.borderVisible = value;
                this.InitializeElement();
                this.Invalidate();
            }
        }

        private LabelNodeStyleObject labelNodeStyle;
        /// <summary>
        /// 标签节点样式(通用)
        /// </summary>
        [Description("标签节点样式(通用)")]
        [Category("杂项")]
        [PropertyOrder(-180)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public LabelNodeStyleObject LabelNodeStyle
        {
            get
            {
                if (this.labelNodeStyle == null)
                    this.labelNodeStyle = new LabelNodeStyleObject(this);
                return this.labelNodeStyle;
            }
        }

        private CategoryNodeStyleObject categoryNodeStyle;
        /// <summary>
        /// 类别节点样式(通用)
        /// </summary>
        [Description("类别节点样式(通用)")]
        [Category("杂项")]
        [PropertyOrder(-179)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public CategoryNodeStyleObject CategoryNodeStyle
        {
            get
            {
                if (this.categoryNodeStyle == null)
                    this.categoryNodeStyle = new CategoryNodeStyleObject(this);
                return this.categoryNodeStyle;
            }
        }

        private ContentNodeStyleObject contentNodeStyle;
        /// <summary>
        /// 内容节点样式(通用)
        /// </summary>
        [Description("内容节点样式(通用)")]
        [Category("杂项")]
        [PropertyOrder(-178)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public ContentNodeStyleObject ContentNodeStyle
        {
            get
            {
                if (this.contentNodeStyle == null)
                    this.contentNodeStyle = new ContentNodeStyleObject(this);
                return this.contentNodeStyle;
            }
        }

        private ScrollBarObject scrollBar;
        /// <summary>
        /// 滚动条
        /// </summary>
        [Description("滚动条")]
        [Category("杂项")]
        [PropertyOrder(-176)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public ScrollBarObject ScrollBar
        {
            get
            {
                if (this.scrollBar == null)
                    this.scrollBar = new ScrollBarObject(this);
                return this.scrollBar;
            }
        }

        private bool multiple = true;
        /// <summary>
        /// 是否允许多个同时展开
        /// </summary>
        [Description("是否允许多个同时展开")]
        [Category("杂项")]
        [PropertyOrder(-174)]
        [DefaultValue(true)]
        public bool Multiple
        {
            get { return this.multiple; }
            set
            {
                if (this.multiple == value)
                    return;

                this.multiple = value;
                this.ExpandCollapse(false);
            }
        }

        private SingleAccordionAlignments alignment = SingleAccordionAlignments.Left;
        /// <summary>
        /// 内容对其方式
        /// </summary>
        [Description("内容对其方式")]
        [Category("杂项")]
        [PropertyOrder(-172)]
        [DefaultValue(SingleAccordionAlignments.Left)]
        public SingleAccordionAlignments Alignment
        {
            get { return this.alignment; }
            set
            {
                if (this.alignment == value)
                    return;

                this.alignment = value;
                this.Invalidate();
            }
        }

        private SingleAccordionNodeCollection nodeCollection;
        /// <summary>
        /// 节点集合（SingleAccordionCategoryNode、SingleAccordionLabelNode、SingleAccordionContentNode）
        /// </summary>
        [Description("节点集合（SingleAccordionCategoryNode、SingleAccordionLabelNode、SingleAccordionContentNode）")]
        [PropertyOrder(-170)]
        [Category("杂项")]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
        public SingleAccordionNodeCollection Nodes
        {
            get
            {
                if (this.nodeCollection == null)
                    this.nodeCollection = new SingleAccordionNodeCollection(this);
                return this.nodeCollection;
            }
        }

        private SingleAccordionContentNode selectedNode = null;
        /// <summary>
        /// 选中的内容节点
        /// </summary>
        [Description("选中的内容节点")]
        [Category("杂项")]
        [Browsable(false)]
        [DefaultValue(null)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public SingleAccordionContentNode SelectedNode
        {
            get { return this.selectedNode; }
            set
            {
                SingleAccordionContentNode tmp = null;
                if (value != null)
                {
                    foreach (SingleAccordionNode node in this.Nodes)
                    {
                        if (node == value)
                        {
                            tmp = value;
                            break;
                        }
                        if (node is SingleAccordionCategoryNode)
                        {
                            SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                            foreach (SingleAccordionContentNode content_node in category_node.Childrens)
                            {
                                if (content_node == value)
                                {
                                    tmp = content_node;
                                    break;
                                }
                            }
                        }
                    }
                }

                if (this.selectedNode == tmp)
                    return;

                this.selectedNode = tmp;
                if (!this.DesignMode)
                {
                    this.OnSelectedNodeChanged(EventArgs.Empty);
                }

                this.Invalidate();
            }
        }

        #endregion

        #region 重写属性

        protected override Size DefaultSize
        {
            get { return new Size(150, 300); }
        }

        protected override ImeMode DefaultImeMode
        {
            get { return ImeMode.Disable; }
        }

        #endregion

        #region 停用属性

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Padding Padding
        {
            get { return base.Padding; }
            set { base.Padding = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new int TabIndex
        {
            get { return base.TabIndex; }
            set { base.TabIndex = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new bool TabStop
        {
            get { return base.TabStop; }
            set { base.TabStop = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new Image BackgroundImage
        {
            get { return base.BackgroundImage; }
            set { base.BackgroundImage = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public new ImageLayout BackgroundImageLayout
        {
            get { return base.BackgroundImageLayout; }
            set { base.BackgroundImageLayout = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override string Text
        {
            get { return base.Text; }
            set { base.Text = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public override RightToLeft RightToLeft
        {
            get { return base.RightToLeft; }
            set { base.RightToLeft = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        public new ImeMode ImeMode
        {
            get { return base.ImeMode; }
            set { base.ImeMode = value; }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color BackColor
        {
            get { return this.StyleAppearance.BackColor; }
            set { }
        }

        [Browsable(false)]
        [EditorBrowsable(EditorBrowsableState.Never)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public override Color ForeColor
        {
            get { return this.StyleAppearance.ContentNode.Normal.TextColor; }
            set { }
        }

        #endregion

        #region 字段

        /// <summary>
        /// 鼠标动画节点列表
        /// </summary>
        private List<SingleAccordionNode> mouseAnimationList = new List<SingleAccordionNode>();

        /// <summary>
        /// 展开折叠节点列表
        /// </summary>
        private List<SingleAccordionCategoryNode> ecAnimationList = new List<SingleAccordionCategoryNode>();

        /// <summary>
        /// 自定义动画节点列表
        /// </summary>
        private List<SingleAccordionCustomAnimation> customAnimationList = new List<SingleAccordionCustomAnimation>();

        /// <summary>
        /// 菜单显示区
        /// </summary>
        private Rectangle displayRectangle = Rectangle.Empty;
        /// <summary>
        /// 菜单真实区(不包含滚动条)
        /// </summary>
        private Rectangle realityRectangle = Rectangle.Empty;
        /// <summary>
        /// 菜单真实区Y偏移量
        /// </summary>
        private int realityRectangle_Y = 0;

        /// <summary>
        /// 鼠标按下功能类型（-1空 、1节点按下、2滚动条按下）
        /// </summary>
        private int mousedownType = -1;
        /// <summary>
        /// 鼠标按下功能对象
        /// </summary>
        private object mousedownObject = null;
        /// <summary>
        /// 鼠标按下功能坐标
        /// </summary>
        private Point mousedownPoint = Point.Empty;
        /// <summary>
        /// 鼠标按下滚动条时菜单真实区的Y坐标
        /// </summary>
        private int mousedownRealityRectangleY = 0;
        /// <summary>
        /// 鼠标进入的节点
        /// </summary>
        private object mouseenterObject = null;

        /// <summary>
        /// 控件正在初始化布局中
        /// </summary>
        private bool initializeing = false;

        /// <summary>
        /// 滚动条当前显示状态
        /// </summary>
        private bool scrollVisible = false;

        #endregion

        public SingleAccordion()
        {
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            SetStyle(ControlStyles.StandardClick, false);//自定义单击事件逻辑
            SetStyle(ControlStyles.StandardDoubleClick, false);//停用双加事件

            this.TabStop = false;
            this.InitializeElement();
            this.OnSkinChanged();
        }

        #region 重写

        protected override void OnScaleDpiChangedInitialize()
        {
            this.InitializeElement();
            this.Invalidate();
        }

        protected override void OnPaint(PaintEventArgs e)
        {
            base.OnPaint(e);

            Graphics g = e.Graphics;

            NativeMethods.TEXTMETRIC font_metrics = ControlHelper.GetFontMetrics(this.Handle, this.Font);
            SolidBrush commom_back_sb = new SolidBrush(Color.White);
            SolidBrush commom_text_sb = new SolidBrush(Color.White);
            Pen commom_fold_pen = new Pen(Color.White, 1);
            Pen commom_splitterline_pen = new Pen(Color.White, 1);

            // 背景
            SingleAccordionBackgroundDrawBeforeEventArgs arg = new SingleAccordionBackgroundDrawBeforeEventArgs(this.ScaleDpi, g, new Rectangle(0, 0, this.ClientRectangle.Width, this.ClientRectangle.Height), false);
            this.OnBackgroundDrawBefore(arg);
            if (arg.Cancel == false)
            {
                SolidBrush back_sb = new SolidBrush(this.StyleAppearance.BackColor);
                g.FillRectangle(back_sb, this.displayRectangle);
                back_sb.Dispose();
            }

            // 节点
            for (int i = 0; i < this.Nodes.Count; i++)
            {
                // 类别节点
                if (this.Nodes[i] is SingleAccordionCategoryNode)
                {
                    SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)this.Nodes[i];
                    if (this.realityRectangle_Y + category_node.Rect.Bottom >= this.displayRectangle.Y && this.realityRectangle_Y + category_node.Rect.Y <= this.displayRectangle.Bottom)
                    {
                        this.DrawCategoryNode(g, category_node, commom_back_sb, commom_text_sb, commom_fold_pen, commom_splitterline_pen, font_metrics);
                    }

                    // 子节点
                    if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanded || category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding || category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)
                    {
                        for (int k = 0; k < category_node.Childrens.Count; k++)
                        {
                            SingleAccordionContentNode content_node = (SingleAccordionContentNode)category_node.Childrens[k];
                            if (this.realityRectangle_Y + content_node.Rect.Bottom >= this.displayRectangle.Y && this.realityRectangle_Y + content_node.Rect.Y <= this.displayRectangle.Bottom)
                            {
                                this.DrawContentNode(g, content_node, commom_back_sb, commom_text_sb, commom_splitterline_pen, font_metrics);
                            }
                        }
                    }

                }
                // 标签节点
                else if (this.Nodes[i] is SingleAccordionLabelNode)
                {
                    SingleAccordionLabelNode label_node = (SingleAccordionLabelNode)this.Nodes[i];
                    if (this.realityRectangle_Y + label_node.Rect.Bottom >= this.displayRectangle.Y && this.realityRectangle_Y + label_node.Rect.Y <= this.displayRectangle.Bottom)
                    {
                        this.DrawLabelNode(g, label_node, commom_back_sb, commom_text_sb, commom_splitterline_pen, font_metrics);
                    }
                }
                // 内容节点
                else if (this.Nodes[i] is SingleAccordionContentNode)
                {
                    SingleAccordionContentNode content_node = (SingleAccordionContentNode)this.Nodes[i];
                    if (this.realityRectangle_Y + content_node.Rect.Bottom >= this.displayRectangle.Y && this.realityRectangle_Y + content_node.Rect.Y <= this.displayRectangle.Bottom)
                    {
                        this.DrawContentNode(g, content_node, commom_back_sb, commom_text_sb, commom_splitterline_pen, font_metrics);
                    }
                }

            }

            if (commom_back_sb != null)
                commom_back_sb.Dispose();
            if (commom_text_sb != null)
                commom_text_sb.Dispose();
            if (commom_fold_pen != null)
                commom_fold_pen.Dispose();
            if (commom_splitterline_pen != null)
                commom_splitterline_pen.Dispose();

            // 滚动条
            if (this.GetScrollVisible() && (!this.ScrollBar.AutoHide || this.ScrollBar.AutoHide && this.scrollVisible))
            {
                // 滑条
                SolidBrush scroll_slider_sb = new SolidBrush((this.mousedownType == 2 || this.ScrollBar.IsMouseEnter) ? this.StyleAppearance.ScrollBar.Enter.TrackBackColor : this.StyleAppearance.ScrollBar.Normal.TrackBackColor);
                g.FillRectangle(scroll_slider_sb, this.ScrollBar.TrackRect);
                scroll_slider_sb.Dispose();

                // 滑块
                int scale_sliderThickness = (int)Math.Ceiling(this.ScrollBar.TrackThickness * this.ScaleDpi);
                Pen scroll_thumb_pen = new Pen((this.mousedownType == 2 || this.ScrollBar.IsMouseEnter) ? this.StyleAppearance.ScrollBar.Enter.ThumbBackColor : this.StyleAppearance.ScrollBar.Normal.ThumbBackColor, scale_sliderThickness);
                if (this.ScrollBar.ThumbRoundEnabled)
                {
                    scroll_thumb_pen.StartCap = LineCap.Round;
                    scroll_thumb_pen.EndCap = LineCap.Round;
                    g.SmoothingMode = SmoothingMode.AntiAlias;
                    g.DrawLine(scroll_thumb_pen, new PointF(this.ScrollBar.ThumbRect.X + scale_sliderThickness / 2, this.ScrollBar.ThumbRect.Y + scale_sliderThickness / 2), new PointF(this.ScrollBar.ThumbRect.X + scale_sliderThickness / 2, this.ScrollBar.ThumbRect.Bottom - scale_sliderThickness / 2));
                }
                else
                {
                    g.DrawLine(scroll_thumb_pen, new PointF(this.ScrollBar.ThumbRect.X + scale_sliderThickness / 2, this.ScrollBar.ThumbRect.Y), new PointF(this.ScrollBar.ThumbRect.X + scale_sliderThickness / 2, this.ScrollBar.ThumbRect.Bottom));
                }
                scroll_thumb_pen.Dispose();
            }

            // 边框
            if (this.BorderVisible)
            {
                Pen border_pen = new Pen(this.StyleAppearance.BorderColor, 1);
                g.DrawRectangle(border_pen, new Rectangle(this.ClientRectangle.X, this.ClientRectangle.Y, this.ClientRectangle.Width - 1, this.ClientRectangle.Height - 1));
                border_pen.Dispose();
            }

        }

        protected override void OnLostFocus(EventArgs e)
        {
            base.OnLostFocus(e);

            this.mousedownType = -1;
            this.mousedownObject = null;
            this.mousedownPoint = Point.Empty;
            this.mouseenterObject = null;
            this.Invalidate();
        }

        protected override void OnEnabledChanged(EventArgs e)
        {
            base.OnEnabledChanged(e);

            if (!this.Enabled)
            {
                this.mousedownType = -1;
                this.mousedownObject = null;
                this.mousedownPoint = Point.Empty;
                this.mouseenterObject = null;
                this.Invalidate();
            }
        }

        protected override void OnVisibleChanged(EventArgs e)
        {
            base.OnVisibleChanged(e);

            if (!this.Visible)
            {
                this.mousedownType = -1;
                this.mousedownObject = null;
                this.mousedownPoint = Point.Empty;
                this.mouseenterObject = null;
                this.Invalidate();
            }
        }

        protected override void OnParentChanged(EventArgs e)
        {
            base.OnParentChanged(e);

            if (this.Parent == null)
            {
                this.mousedownType = -1;
                this.mousedownObject = null;
                this.mousedownPoint = Point.Empty;
                this.mouseenterObject = null;
                this.Invalidate();
            }
        }

        protected override void OnMouseEnter(EventArgs e)
        {
            base.OnMouseEnter(e);

            this.scrollVisible = true;
            this.Invalidate();
        }

        protected override void OnMouseLeave(EventArgs e)
        {
            base.OnMouseLeave(e);

            this.scrollVisible = false;
            this.mousedownType = -1;
            this.mousedownObject = null;
            this.mousedownPoint = Point.Empty;
            this.mouseenterObject = null;
            this.AddNodeMouseAnimation(this.PointToClient(Control.MousePosition));
            this.Invalidate();
        }

        protected override void OnMouseDown(MouseEventArgs e)
        {
            if (!this.Focused)
            {
                this.Focus();
            }

            if (e.Button == MouseButtons.Left)
            {
                this.mousedownPoint = e.Location;

                if (this.GetScrollVisible() && this.ScrollBar.TrackRect.Contains(e.Location))
                {
                    if (this.ScrollBar.ThumbRect.Contains(e.Location))
                    {
                        this.mousedownType = 2;
                        this.mousedownObject = this.ScrollBar;
                        this.mousedownRealityRectangleY = this.realityRectangle_Y;
                        return;
                    }
                }
                else if (this.displayRectangle.Contains(e.Location))
                {
                    Point reality_mousePoint = new Point(e.Location.X, -this.realityRectangle_Y + e.Location.Y);
                    foreach (SingleAccordionNode node in this.Nodes)
                    {
                        if (node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= node.Rect.Bottom)
                        {
                            this.mousedownType = 1;
                            this.mousedownObject = node;
                            return;
                        }
                        if (node is SingleAccordionCategoryNode)
                        {
                            SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                            if (category_node.ECAnimationStatus != SingleAccordionNodeECAnimationStatuss.Collapseed && category_node.ContainerRect.Contains(reality_mousePoint))
                            {
                                foreach (SingleAccordionContentNode content_node in category_node.Childrens)
                                {
                                    if (content_node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= content_node.Rect.Bottom)
                                    {
                                        this.mousedownType = 1;
                                        this.mousedownObject = content_node;
                                        return;
                                    }
                                }
                            }
                        }
                    }

                }

                this.mousedownType = -1;
                this.mousedownObject = null;
            }

            base.OnMouseDown(e);
        }

        protected override void OnMouseUp(MouseEventArgs e)
        {
            if (e.Button == MouseButtons.Left)
            {
                if (this.mousedownType == 1)
                {
                    if (this.displayRectangle.Contains(e.Location) && (!this.GetScrollVisible() || e.Location.X < this.ScrollBar.TrackRect.X))
                    {
                        Point reality_mousePoint = new Point(e.Location.X, -this.realityRectangle_Y + e.Location.Y);
                        Type node_type = this.mousedownObject.GetType();

                        if (node_type == typeof(SingleAccordionLabelNode))
                        {
                            SingleAccordionLabelNode label_node_tmp = (SingleAccordionLabelNode)this.mousedownObject;
                            if (label_node_tmp.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= label_node_tmp.Rect.Bottom)
                            {
                                this.OnNodeClick(new SingleAccordionNodeEventArgs(label_node_tmp));
                                this.Invalidate();
                            }
                        }
                        else if (node_type == typeof(SingleAccordionCategoryNode))
                        {
                            SingleAccordionCategoryNode category_node_tmp = (SingleAccordionCategoryNode)this.mousedownObject;
                            if (category_node_tmp.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= category_node_tmp.Rect.Bottom)
                            {
                                //折叠
                                if (category_node_tmp.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanded || category_node_tmp.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
                                {
                                    if (category_node_tmp.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
                                    {
                                        category_node_tmp.ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer - category_node_tmp.ECAnimationUsedTime;
                                    }
                                    category_node_tmp.ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Collapseing;
                                }
                                //展开
                                else
                                {
                                    if (!this.Multiple)
                                    {
                                        SingleAccordionCategoryNode[] nodes = this.FindExpand();
                                        for (int i = 0; i < nodes.Length; i++)
                                        {
                                            if (nodes[i].ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
                                            {
                                                nodes[i].ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer - nodes[i].ECAnimationUsedTime;
                                            }
                                            nodes[i].ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Collapseing;
                                            if (this.ecAnimationList.IndexOf(nodes[i]) == -1)
                                            {
                                                this.ecAnimationList.Add(nodes[i]);
                                            }
                                        }
                                    }
                                    if (category_node_tmp.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)
                                    {
                                        category_node_tmp.ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer - category_node_tmp.ECAnimationUsedTime;
                                    }
                                    category_node_tmp.ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Expanding;
                                }
                                if (this.ecAnimationList.IndexOf(category_node_tmp) == -1)
                                {
                                    this.ecAnimationList.Add(category_node_tmp);
                                }
                                this.IntervalTimerStart();

                                this.OnNodeClick(new SingleAccordionNodeEventArgs(category_node_tmp));
                                this.Invalidate();
                            }
                        }
                        else if (node_type == typeof(SingleAccordionContentNode))
                        {
                            SingleAccordionContentNode content_node_tmp = (SingleAccordionContentNode)this.mousedownObject;
                            if (content_node_tmp.Parent != null)
                            {
                                SingleAccordionCategoryNode category_node_tmp = content_node_tmp.Parent as SingleAccordionCategoryNode;
                                if (category_node_tmp != null && category_node_tmp.ECAnimationStatus != SingleAccordionNodeECAnimationStatuss.Collapseed && category_node_tmp.ContainerRect.Contains(reality_mousePoint))
                                {
                                    if (content_node_tmp.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= content_node_tmp.Rect.Bottom)
                                    {
                                        this.OnNodeClick(new SingleAccordionNodeEventArgs(content_node_tmp));
                                        this.SelectedNode = content_node_tmp;
                                        this.Invalidate();
                                    }
                                }
                            }
                            else if (content_node_tmp.Owner != null)
                            {
                                if (content_node_tmp.Rect.Contains(reality_mousePoint))
                                {
                                    this.OnNodeClick(new SingleAccordionNodeEventArgs(content_node_tmp));
                                    this.SelectedNode = content_node_tmp;
                                    this.Invalidate();
                                }
                            }
                        }

                    }
                }
            }
            this.mousedownType = -1;
            this.mousedownObject = null;
            this.AddNodeMouseAnimation(e.Location);
            this.Invalidate();

            base.OnMouseUp(e);
        }

        protected override void OnMouseMove(MouseEventArgs e)
        {
            base.OnMouseMove(e);

            if (this.mousedownType == -1)
            {
                object mouseenterObject_tmp = null;
                if (this.GetScrollVisible() && this.ScrollBar.TrackRect.Contains(e.Location))
                {
                    if (this.ScrollBar.ThumbRect.Contains(e.Location))
                    {
                        mouseenterObject_tmp = this.ScrollBar;
                    }
                }
                else if (this.displayRectangle.Contains(e.Location))
                {
                    Point reality_mousePoint = new Point(e.Location.X, -this.realityRectangle_Y + e.Location.Y);
                    foreach (SingleAccordionNode node in this.Nodes)
                    {
                        if (node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= node.Rect.Bottom)
                        {
                            mouseenterObject_tmp = node;
                            goto result_node;
                        }
                        if (node is SingleAccordionCategoryNode)
                        {
                            SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                            if (category_node.ECAnimationStatus != SingleAccordionNodeECAnimationStatuss.Collapseed && category_node.ContainerRect.Contains(reality_mousePoint))
                            {
                                foreach (SingleAccordionContentNode content_node in category_node.Childrens)
                                {
                                    if (content_node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= content_node.Rect.Bottom)
                                    {
                                        mouseenterObject_tmp = content_node;
                                        goto result_node;
                                    }
                                }
                            }
                        }
                    }

                }

            result_node:
                if (this.mouseenterObject != mouseenterObject_tmp)
                {
                    this.mouseenterObject = mouseenterObject_tmp;
                    this.Invalidate();
                }
                this.AddNodeMouseAnimation(e.Location);
            }
            else if (this.mousedownType == 2)
            {
                int new_y = this.mousedownRealityRectangleY - (int)((this.realityRectangle.Height - this.displayRectangle.Height) * (e.Location.Y - this.mousedownPoint.Y) / (float)(this.ScrollBar.TrackRect.Height - this.ScrollBar.ThumbRect.Height));
                if (new_y < this.displayRectangle.Height - this.realityRectangle.Height)
                {
                    new_y = this.displayRectangle.Height - this.realityRectangle.Height;
                }
                if (new_y > 0)
                {
                    new_y = 0;
                }

                if (this.realityRectangle_Y != new_y)
                {
                    this.realityRectangle_Y = new_y;
                    this.UpdateScrollRectangle();
                    this.Invalidate();
                }
            }

        }

        protected override void OnMouseWheel(MouseEventArgs e)
        {
            base.OnMouseWheel(e);

            int scale_category_node_height = (int)Math.Ceiling(this.CategoryNodeStyle.Height * this.ScaleDpi);
            int scale_content_node_height = (int)Math.Ceiling(this.ContentNodeStyle.Height * this.ScaleDpi);
            int wheel = (int)Math.Ceiling(Math.Min(scale_category_node_height, scale_content_node_height) / 2f);

            int offset = e.Delta > 1 ? -wheel : wheel;
            int new_y = this.realityRectangle_Y - offset;
            if (new_y < this.displayRectangle.Height - this.realityRectangle.Height)
            {
                new_y = this.displayRectangle.Height - this.realityRectangle.Height;
            }
            if (new_y > 0)
            {
                new_y = 0;
            }

            if (this.realityRectangle_Y != new_y)
            {
                this.realityRectangle_Y = new_y;
                this.UpdateScrollRectangle();
                this.Invalidate();
            }
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);

            int border = this.BorderVisible ? 1 : 0;
            this.displayRectangle = new Rectangle(this.ClientRectangle.X + border, this.ClientRectangle.Y + border, this.ClientRectangle.Width - border * 2, this.ClientRectangle.Height - border * 2);
            this.realityRectangle = new Rectangle(this.displayRectangle.X, this.displayRectangle.Y, this.displayRectangle.Width, this.realityRectangle.Height);
            this.UpdateAllNodeRectangle();
            this.UpdateScrollRectangle();
            this.Invalidate();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                MainThreadAnimationControl.AnimationStop(this);
            }

            base.Dispose(disposing);
        }

        /// <summary>
        /// 动画控件动画中要处理的内容(不能时耗时操作)
        /// </summary>
        /// <param name="interval">动画定时器间隔时间</param>
        protected override void Animationing(int interval)
        {
            bool isLayout = false;

            #region 鼠标进入离开

            for (int i = 0; i < this.mouseAnimationList.Count; i++)
            {
                this.mouseAnimationList[i].MouseAnimationUsedTime += interval;
                int allTime = this.GetProperty_MouseAnimationAllTimer(mouseAnimationList[i]);
                if (mouseAnimationList[i].MouseAnimationUsedTime > allTime)
                {
                    this.mouseAnimationList[i].MouseAnimationUsedTime = allTime;
                }
                if (mouseAnimationList[i].MouseAnimationUsedTime == allTime)
                {
                    if (mouseAnimationList[i].MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                    {
                        this.mouseAnimationList[i].MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseEnter;
                        this.mouseAnimationList[i].MouseAnimationUsedTime = 0;
                    }
                    else if (mouseAnimationList[i].MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                    {
                        this.mouseAnimationList[i].MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseLeave;
                        this.mouseAnimationList[i].MouseAnimationUsedTime = 0;
                    }
                }
            }

            List<SingleAccordionNode> mouseAnimationList_tmp = new List<SingleAccordionNode>();
            for (int i = 0; i < this.mouseAnimationList.Count; i++)
            {
                if (this.mouseAnimationList[i].MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering || this.mouseAnimationList[i].MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                {
                    mouseAnimationList_tmp.Add(this.mouseAnimationList[i]);
                }
            }
            this.mouseAnimationList = mouseAnimationList_tmp;

            #endregion

            #region  展开折叠

            for (int i = 0; i < this.ecAnimationList.Count; i++)
            {
                isLayout = true;
                this.ecAnimationList[i].ECAnimationUsedTime += interval;
                if (this.ecAnimationList[i].ECAnimationUsedTime > this.CategoryNodeStyle.ECAnimationAllTimer)
                {
                    this.ecAnimationList[i].ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer;
                }

                if (this.ecAnimationList[i].ECAnimationUsedTime == this.CategoryNodeStyle.ECAnimationAllTimer)
                {
                    if (this.ecAnimationList[i].ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
                    {
                        this.ecAnimationList[i].ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Expanded;
                    }
                    else if (this.ecAnimationList[i].ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)
                    {
                        this.ecAnimationList[i].ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Collapseed;
                    }
                    this.ecAnimationList[i].ECAnimationUsedTime = 0;
                }
            }

            List<SingleAccordionCategoryNode> ecAnimationList_tmp = new List<SingleAccordionCategoryNode>();
            for (int i = 0; i < this.ecAnimationList.Count; i++)
            {
                if (this.ecAnimationList[i].ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding || this.ecAnimationList[i].ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)
                {
                    ecAnimationList_tmp.Add(this.ecAnimationList[i]);
                }
            }
            this.ecAnimationList = ecAnimationList_tmp;

            #endregion

            #region  自定义

            List<SingleAccordionCustomAnimation> customAnimationList_tmp = new List<SingleAccordionCustomAnimation>();
            for (int i = 0; i < this.customAnimationList.Count; i++)
            {
                if (this.customAnimationList[i].AnimationUsedTime >= this.customAnimationList[i].AnimationAllTime)
                {
                    customAnimationList_tmp.Add(this.customAnimationList[i]);
                }
                else
                {
                    this.customAnimationList[i].AnimationUsedTime += interval;
                    if (this.customAnimationList[i].AnimationUsedTime > this.customAnimationList[i].AnimationAllTime)
                    {
                        this.customAnimationList[i].AnimationUsedTime = this.customAnimationList[i].AnimationAllTime;
                    }
                    if (this.customAnimationList[i].IsLayout)
                    {
                        isLayout = true;
                    }
                }
            }

            for (int i = 0; i < customAnimationList_tmp.Count; i++)
            {
                this.customAnimationList.Remove(customAnimationList_tmp[i]);
            }

            #endregion

            this.IntervalTimerStop();

            if (isLayout)
            {
                this.UpdateRealityRectangle();
                this.UpdateAllNodeRectangle();
                this.UpdateScrollRectangle();
            }
            this.Invalidate();

        }

        #endregion

        #region 虚方法

        protected virtual void OnBackgroundDrawBefore(SingleAccordionBackgroundDrawBeforeEventArgs e)
        {
            SingleAccordionBackgroundDrawBeforeEventHandler handler = Events[EventBackgroundDrawBefore] as SingleAccordionBackgroundDrawBeforeEventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        protected virtual void OnNodeDrawBefore(SingleAccordionNodeDrawBeforeEventArgs e)
        {
            SingleAccordionNodeDrawBeforeEventHandler handler = Events[EventNodeDrawBefore] as SingleAccordionNodeDrawBeforeEventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        protected virtual void OnNodeDrawAfter(SingleAccordionNodeDrawAfterEventArgs e)
        {
            SingleAccordionNodeDrawAfterEventHandler handler = Events[EventNodeDrawAfter] as SingleAccordionNodeDrawAfterEventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        protected virtual void OnNodeClick(SingleAccordionNodeEventArgs e)
        {
            NodeClickEventHandler handler = Events[EventNodeClick] as NodeClickEventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        protected virtual void OnSelectedNodeChanged(EventArgs e)
        {
            EventHandler handler = Events[EventSelectedNodeChanged] as EventHandler;
            if (handler != null)
            {
                handler(this, e);
            }
        }

        #endregion

        #region  公开方法

        /// <summary>
        /// 展开或折叠所有节点 (Multiple=True 时展开才生效)
        /// </summary>
        /// <param name="isExpand">是否展开</param>
        public void ExpandCollapse(bool isExpand)
        {
            if (this.Multiple || (!this.Multiple && !isExpand))
            {
                this.initializeing = true;
                foreach (SingleAccordionNode node in this.Nodes)
                {
                    if (node is SingleAccordionCategoryNode)
                    {
                        ((SingleAccordionCategoryNode)node).Expand = isExpand;
                    }
                }
                this.initializeing = false;

                this.InitializeElement();
                this.Invalidate();
            }
        }

        /// <summary>
        /// 展开或折叠指定节点
        /// </summary>
        /// <param name="categoryNode">指定节点</param>
        /// <param name="isExpand">是否展开</param>
        /// <param name="animation">是否有动画效果</param>
        public void ExpandCollapse(SingleAccordionCategoryNode categoryNode, bool isExpand, bool animation)
        {
            if (categoryNode.Expand == isExpand)
                return;

            if (animation)
            {
                //折叠
                if (categoryNode.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanded || categoryNode.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)//折叠
                {
                    if (categoryNode.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
                    {
                        categoryNode.ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer - categoryNode.ECAnimationUsedTime;
                    }
                    categoryNode.ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Collapseing;
                }
                //展开
                else
                {
                    if (!this.Multiple)
                    {
                        SingleAccordionCategoryNode[] nodes = this.FindExpand();
                        for (int i = 0; i < nodes.Length; i++)
                        {
                            if (nodes[i].ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
                            {
                                nodes[i].ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer - nodes[i].ECAnimationUsedTime;
                            }
                            nodes[i].ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Collapseing;
                            if (this.ecAnimationList.IndexOf(nodes[i]) == -1)
                            {
                                this.ecAnimationList.Add(nodes[i]);
                            }
                        }
                    }
                    if (categoryNode.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)
                    {
                        categoryNode.ECAnimationUsedTime = this.CategoryNodeStyle.ECAnimationAllTimer - categoryNode.ECAnimationUsedTime;
                    }
                    categoryNode.ECAnimationStatus = SingleAccordionNodeECAnimationStatuss.Expanding;
                }
                if (this.ecAnimationList.IndexOf(categoryNode) == -1)
                {
                    this.ecAnimationList.Add(categoryNode);
                }
                this.IntervalTimerStart();
            }
            else
            {
                this.initializeing = true;
                if (!this.Multiple && isExpand)
                {
                    foreach (SingleAccordionNode node in this.Nodes)
                    {
                        if (node == categoryNode)
                        {
                            ((SingleAccordionCategoryNode)node).Expand = false;
                        }
                    }
                }
                categoryNode.Expand = isExpand;
                this.initializeing = false;

                this.InitializeElement();
                this.Invalidate();
            }
        }

        /// <summary>
        /// 查找已展开的节点
        /// </summary>
        /// <returns></returns>
        public SingleAccordionCategoryNode[] FindExpand()
        {
            List<SingleAccordionCategoryNode> list = new List<SingleAccordionCategoryNode>();
            for (int i = 0; i < this.Nodes.Count; i++)
            {
                SingleAccordionCategoryNode category_node = this.Nodes[i] as SingleAccordionCategoryNode;
                if (category_node != null && category_node.Expand)
                {
                    list.Add(category_node);
                }
            }

            return list.ToArray();
        }

        /// <summary>
        /// 添加自定义动画（key、target 组合作为索引）
        /// </summary>
        /// <param name="key">动画类型标识</param>
        /// <param name="target">动画作用目标</param>
        /// <param name="animationUsedTime">自定义动画已使用时间</param>
        /// <param name="animationAllTime">自定义动画总时间</param>
        /// <param name="isLayout">自定义动画是否涉及控件内部布局计算</param>
        /// <param name="tag">动画自定义数据</param>
        public void AddCustomAnimation(string key, object target, int animationUsedTime, int animationAllTime, bool isLayout, object tag)
        {
            key = key.Trim();

            if (key == "" || target == null)
                return;

            for (int i = 0; i < this.customAnimationList.Count; i++)
            {
                if (this.customAnimationList[i].Key == key && this.customAnimationList[i].Target == target)
                {
                    return;
                }
            }
            this.customAnimationList.Add(new SingleAccordionCustomAnimation(key, target, animationUsedTime, animationAllTime, isLayout, tag));
            this.IntervalTimerStart();
        }

        /// <summary>
        /// 移除自定义动画
        /// </summary>
        /// <param name="key">动画类型标识</param>
        /// <param name="target">动画作用目标</param>
        public void RemoveCustomAnimation(string key, object target)
        {
            key = key.Trim();

            if (key == "" || target == null)
                return;

            SingleAccordionCustomAnimation customAnimation = null;
            for (int i = 0; i < this.customAnimationList.Count; i++)
            {
                if (this.customAnimationList[i].Key == key && this.customAnimationList[i].Target == target)
                {
                    customAnimation = this.customAnimationList[i];
                    break;
                }
            }
            if (customAnimation != null)
            {
                this.customAnimationList.Remove(customAnimation);
                this.IntervalTimerStop();

                if (customAnimation.IsLayout)
                {
                    this.UpdateRealityRectangle();
                    this.UpdateAllNodeRectangle();
                    this.UpdateScrollRectangle();
                }
                this.Invalidate();
            }
        }

        /// <summary>
        /// 查找自定义动画
        /// </summary>
        /// <param name="key">动画类型标识</param>
        /// <param name="target">动画作用目标</param>
        public SingleAccordionCustomAnimation FindCustomAnimation(string key, object target)
        {
            key = key.Trim();

            if (key == "" || target == null)
                return null;

            for (int i = 0; i < this.customAnimationList.Count; i++)
            {
                if (this.customAnimationList[i].Key == key && this.customAnimationList[i].Target == target)
                {
                    return this.customAnimationList[i];
                }
            }

            return null;
        }

        /// <summary>
        /// 设置指定内容节点为选中节点（但不触发SelectedNodeChanged事件）
        /// </summary>
        /// <param name="contentNode">内容节点</param>
        public void UpdateSelectedNode(SingleAccordionContentNode contentNode)
        {
            SingleAccordionContentNode tmp = null;
            if (contentNode != null)
            {
                foreach (SingleAccordionNode node in this.Nodes)
                {
                    if (node == contentNode)
                    {
                        tmp = contentNode;
                        break;
                    }
                    if (node is SingleAccordionCategoryNode)
                    {
                        SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                        foreach (SingleAccordionContentNode content_node in category_node.Childrens)
                        {
                            if (content_node == contentNode)
                            {
                                tmp = contentNode;
                                break;
                            }
                        }
                    }
                }
            }

            if (this.selectedNode == tmp)
                return;

            this.selectedNode = tmp;
            this.Invalidate();
        }

        /// <summary>
        /// 根据鼠标坐标获取节点
        /// </summary>
        /// <param name="mousePoint">鼠标坐标(相对于控件)</param>
        /// <returns>没有返回null</returns>
        public SingleAccordionNode GetNodeByPoint(Point mousePoint)
        {
            if (this.displayRectangle.Contains(mousePoint))
            {
                Point reality_mousePoint = new Point(mousePoint.X, -this.realityRectangle_Y + mousePoint.Y);
                foreach (SingleAccordionNode node in this.Nodes)
                {
                    if (node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= node.Rect.Bottom)
                    {
                        return node;
                    }
                    if (node is SingleAccordionCategoryNode)
                    {
                        SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                        if (category_node.ECAnimationStatus != SingleAccordionNodeECAnimationStatuss.Collapseed && category_node.ContainerRect.Contains(reality_mousePoint))
                        {
                            foreach (SingleAccordionContentNode content_node in category_node.Childrens)
                            {
                                if (content_node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= content_node.Rect.Bottom)
                                {
                                    return content_node;
                                }
                            }
                        }
                    }
                }

            }

            return null;
        }

        /// <summary>
        /// 获取滚动条位置
        /// </summary>
        /// <returns></returns>
        public int GetScrollY()
        {
            return this.realityRectangle_Y;
        }

        /// <summary>
        /// 鼠标是否进入节点
        /// </summary>
        /// <param name="node">节点</param>
        /// <returns></returns>
        internal bool IsMouseEnter(object node)
        {
            return (node != null && this.mouseenterObject == node);
        }



        /// <summary>
        /// 获取指定节点鼠标动画启用状态
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public bool GetProperty_MouseAnimationEnabled(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.MouseAnimationEnabled == SingleAccordionMouseAnimationEnableds.Auto)
            {
                if (node is SingleAccordionCategoryNode)
                {
                    return this.CategoryNodeStyle.MouseAnimationEnabled;
                }
                else if (node is SingleAccordionLabelNode)
                {
                    return this.LabelNodeStyle.MouseAnimationEnabled;
                }
                else
                {
                    return this.ContentNodeStyle.MouseAnimationEnabled;
                }
            }
            else
            {
                return node.MouseAnimationEnabled == SingleAccordionMouseAnimationEnableds.True ? true : false;
            }

        }

        /// <summary>
        /// 获取指定节点鼠标动画总时间
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public int GetProperty_MouseAnimationAllTimer(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node is SingleAccordionCategoryNode)
            {
                return this.CategoryNodeStyle.MouseAnimationAllTimer;
            }
            else if (node is SingleAccordionLabelNode)
            {
                return this.LabelNodeStyle.MouseAnimationAllTimer;
            }
            else
            {
                return this.ContentNodeStyle.MouseAnimationAllTimer;
            }

        }

        /// <summary>
        /// 获取指定节点左右滑动动画距离
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public int GetProperty_LRSlidingDistance(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.LRAnimationDistance == -1)
            {
                if (node is SingleAccordionCategoryNode)
                {
                    return (int)Math.Ceiling(this.CategoryNodeStyle.LRAnimationDistance * this.ScaleDpi);
                }
                else if (node is SingleAccordionLabelNode)
                {
                    return (int)Math.Ceiling(this.LabelNodeStyle.LRAnimationDistance * this.ScaleDpi);
                }
                else
                {
                    return (int)Math.Ceiling(this.ContentNodeStyle.LRAnimationDistance * this.ScaleDpi);
                }
            }
            else
            {
                return node.LRAnimationDistance;
            }

        }

        /// <summary>
        /// 获取指定节点上下外边距
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public TBMargin GetProperty_TBMargin(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            TBMargin commomTBMargin = this.ContentNodeStyle.TBMargin;
            if (node is SingleAccordionCategoryNode)
            {
                commomTBMargin = this.CategoryNodeStyle.TBMargin;
            }
            else if (node is SingleAccordionLabelNode)
            {
                commomTBMargin = this.LabelNodeStyle.TBMargin;
            }

            int top = node.TBMargin.Top == -1 ? commomTBMargin.Top : node.TBMargin.Top;
            int bottom = node.TBMargin.Bottom == -1 ? commomTBMargin.Bottom : node.TBMargin.Bottom;

            return new TBMargin((int)Math.Ceiling(top * this.ScaleDpi), (int)Math.Ceiling(bottom * this.ScaleDpi));

        }

        /// <summary>
        /// 获取指定节点文本外左右外边距
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public LRMargin GetProperty_TextLRMargin(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            LRMargin commomLRMargin = this.ContentNodeStyle.TextLRMargin;
            if (node is SingleAccordionCategoryNode)
            {
                commomLRMargin = this.CategoryNodeStyle.TextLRMargin;
            }
            else if (node is SingleAccordionLabelNode)
            {
                commomLRMargin = this.LabelNodeStyle.TextLRMargin;
            }

            int left = node.TextLRMargin.Left == -1 ? commomLRMargin.Left : node.TextLRMargin.Left;
            int right = node.TextLRMargin.Right == -1 ? commomLRMargin.Right : node.TextLRMargin.Right;

            return new LRMargin((int)Math.Ceiling(left * this.ScaleDpi), (int)Math.Ceiling(right * this.ScaleDpi));

        }

        /// <summary>
        /// 获取指定节点背景颜色
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public Color GetProperty_NodeBackColor(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node is SingleAccordionCategoryNode)
            {
                SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                if (this.Enabled && category_node.IsMouseEnter)
                {
                    return (category_node.StyleAppearance.Enter.BackColor == Color.Empty) ? this.StyleAppearance.CategoryNode.Enter.BackColor : category_node.StyleAppearance.Enter.BackColor;
                }
                else
                {
                    return (category_node.StyleAppearance.Normal.BackColor == Color.Empty) ? this.StyleAppearance.CategoryNode.Normal.BackColor : category_node.StyleAppearance.Normal.BackColor;
                }
            }
            else if (node is SingleAccordionLabelNode)
            {
                SingleAccordionLabelNode label_node = (SingleAccordionLabelNode)node;
                if (this.Enabled && label_node.IsMouseEnter)
                {
                    return (label_node.StyleAppearance.Enter.BackColor == Color.Empty) ? this.StyleAppearance.LabelNode.Enter.BackColor : label_node.StyleAppearance.Enter.BackColor;
                }
                else
                {
                    return (label_node.StyleAppearance.Normal.BackColor == Color.Empty) ? this.StyleAppearance.LabelNode.Normal.BackColor : label_node.StyleAppearance.Normal.BackColor;
                }
            }
            else
            {
                SingleAccordionContentNode content_node = (SingleAccordionContentNode)node;
                if (content_node == this.SelectedNode)
                {
                    return (content_node.StyleAppearance.Selected.BackColor == Color.Empty) ? this.StyleAppearance.ContentNode.Selected.BackColor : content_node.StyleAppearance.Selected.BackColor;
                }
                else if (this.Enabled && content_node.IsMouseEnter)
                {
                    return (content_node.StyleAppearance.Enter.BackColor == Color.Empty) ? this.StyleAppearance.ContentNode.Enter.BackColor : content_node.StyleAppearance.Enter.BackColor;
                }
                else
                {
                    return (content_node.StyleAppearance.Normal.BackColor == Color.Empty) ? this.StyleAppearance.ContentNode.Normal.BackColor : content_node.StyleAppearance.Normal.BackColor;
                }
            }

        }

        /// <summary>
        /// 获取指定节点文本颜色
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public Color GetProperty_NodeTextColor(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node is SingleAccordionCategoryNode)
            {
                SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                if (this.Enabled && category_node.IsMouseEnter)
                {
                    return (category_node.StyleAppearance.Enter.TextColor == Color.Empty) ? this.StyleAppearance.CategoryNode.Enter.TextColor : category_node.StyleAppearance.Enter.TextColor;
                }
                else
                {
                    return (category_node.StyleAppearance.Normal.TextColor == Color.Empty) ? this.StyleAppearance.CategoryNode.Normal.TextColor : category_node.StyleAppearance.Normal.TextColor;
                }
            }
            else if (node is SingleAccordionLabelNode)
            {
                SingleAccordionLabelNode label_node = (SingleAccordionLabelNode)node;
                if (this.Enabled && label_node.IsMouseEnter)
                {
                    return (label_node.StyleAppearance.Enter.TextColor == Color.Empty) ? this.StyleAppearance.LabelNode.Enter.TextColor : label_node.StyleAppearance.Enter.TextColor;
                }
                else
                {
                    return (label_node.StyleAppearance.Normal.TextColor == Color.Empty) ? this.StyleAppearance.LabelNode.Normal.TextColor : label_node.StyleAppearance.Normal.TextColor;
                }
            }
            else
            {
                SingleAccordionContentNode content_node = (SingleAccordionContentNode)node;
                if (content_node == this.SelectedNode)
                {
                    return (content_node.StyleAppearance.Selected.TextColor == Color.Empty) ? this.StyleAppearance.ContentNode.Selected.TextColor : content_node.StyleAppearance.Selected.TextColor;
                }
                else if (this.Enabled && content_node.IsMouseEnter)
                {
                    return (content_node.StyleAppearance.Enter.TextColor == Color.Empty) ? this.StyleAppearance.ContentNode.Enter.TextColor : content_node.StyleAppearance.Enter.TextColor;
                }
                else
                {
                    return (content_node.StyleAppearance.Normal.TextColor == Color.Empty) ? this.StyleAppearance.ContentNode.Normal.TextColor : content_node.StyleAppearance.Normal.TextColor;
                }
            }

        }

        /// <summary>
        /// 获取指定节点折叠按钮颜色
        /// </summary>
        /// <param name="category_node">指定节点</param>
        /// <returns></returns>
        public Color GetProperty_NodeFoldColor(SingleAccordionCategoryNode category_node)
        {
            if (category_node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (this.Enabled && category_node.IsMouseEnter)
            {
                return (category_node.StyleAppearance.Enter.FoldColor == Color.Empty) ? this.StyleAppearance.CategoryNode.Enter.FoldColor : category_node.StyleAppearance.Enter.FoldColor;
            }
            else
            {
                return (category_node.StyleAppearance.Normal.FoldColor == Color.Empty) ? this.StyleAppearance.CategoryNode.Normal.FoldColor : category_node.StyleAppearance.Normal.FoldColor;
            }

        }

        /// <summary>
        /// 获取指定节点分隔线颜色
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public Color GetProperty_NodeSplitterLineColor(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node is SingleAccordionCategoryNode)
            {
                SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                if (category_node.StyleAppearance.SplitterLineColor != Color.Empty)
                {
                    return category_node.StyleAppearance.SplitterLineColor;
                }
                else
                {
                    return this.StyleAppearance.CategoryNode.SplitterLineColor;
                }
            }
            else if (node is SingleAccordionContentNode)
            {
                SingleAccordionContentNode content_node = (SingleAccordionContentNode)node;
                if (content_node.StyleAppearance.SplitterLineColor != Color.Empty)
                {
                    return content_node.StyleAppearance.SplitterLineColor;
                }
                else
                {
                    return this.StyleAppearance.ContentNode.SplitterLineColor;
                }
            }
            else
            {
                SingleAccordionLabelNode label_node = (SingleAccordionLabelNode)node;
                if (label_node.StyleAppearance.SplitterLineColor != Color.Empty)
                {
                    return label_node.StyleAppearance.SplitterLineColor;
                }
                else
                {
                    return this.StyleAppearance.LabelNode.SplitterLineColor;
                }
            }

        }

        /// <summary>
        /// 获取指定节点是否显示图片(根据显示状态、内容对齐方式)
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public bool GetProperty_NodeImageVisible(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (this.Alignment == SingleAccordionAlignments.Center)
            {
                return false;
            }

            if (node.ImageVisible == SingleAccordionNodeImageVisibles.Auto)
            {
                if (node is SingleAccordionCategoryNode)
                {
                    return this.CategoryNodeStyle.ImageVisible;
                }
                else if (node is SingleAccordionLabelNode)
                {
                    return this.LabelNodeStyle.ImageVisible;
                }
                else
                {
                    return this.ContentNodeStyle.ImageVisible;
                }
            }
            else
            {
                return node.ImageVisible == SingleAccordionNodeImageVisibles.True ? true : false;
            }

        }

        /// <summary>
        /// 获取指定节点图片左右外边距(根据显示状态、内容对齐方式)
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public LRMargin GetProperty_NodeImageLRMargin(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (!this.GetProperty_NodeImageVisible(node))
            {
                return new LRMargin(0);
            }

            LRMargin commomLRMargin = this.ContentNodeStyle.ImageLRMargin;
            if (node is SingleAccordionCategoryNode)
            {
                commomLRMargin = this.CategoryNodeStyle.ImageLRMargin;
            }
            else if (node is SingleAccordionLabelNode)
            {
                commomLRMargin = this.LabelNodeStyle.ImageLRMargin;
            }

            int left = node.ImageLRMargin.Left == -1 ? commomLRMargin.Left : node.ImageLRMargin.Left;
            int right = node.ImageLRMargin.Right == -1 ? commomLRMargin.Right : node.ImageLRMargin.Right;

            return new LRMargin((int)Math.Ceiling(left * this.ScaleDpi), (int)Math.Ceiling(right * this.ScaleDpi));

        }

        /// <summary>
        /// 获取指定节点图片Size(根据显示状态、内容对齐方式)
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public Size GetProperty_NodeImageSize(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }
            if (!this.GetProperty_NodeImageVisible(node))
            {
                return new Size(0, 0);
            }

            Size commomBackSize = this.ContentNodeStyle.ImageSize;
            if (node is SingleAccordionCategoryNode)
            {
                return this.CategoryNodeStyle.ImageSize;
            }
            else if (node is SingleAccordionLabelNode)
            {
                return this.LabelNodeStyle.ImageSize;
            }

            int width = node.ImageSize.Width == -1 ? commomBackSize.Width : node.ImageSize.Width;
            int height = node.ImageSize.Height == -1 ? commomBackSize.Height : node.ImageSize.Height;

            return new Size((int)Math.Ceiling(width * this.ScaleDpi), (int)Math.Ceiling(height * this.ScaleDpi));

        }

        /// <summary>
        /// 获取指定节点图片
        /// </summary>
        /// <param name="node">指定节点</param>
        /// <returns></returns>
        public Image GetProperty_Image(SingleAccordionNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            if (node.Image == null)
            {
                if (node is SingleAccordionCategoryNode)
                {
                    return this.CategoryNodeStyle.Image;
                }
                else if (node is SingleAccordionLabelNode)
                {
                    return this.LabelNodeStyle.Image;
                }
                else
                {
                    return this.ContentNodeStyle.Image;
                }
            }
            else
            {
                return node.Image;
            }

        }

        /// <summary>
        /// 获取折叠图标显示状态(根据内容对齐方式)
        /// </summary>
        /// <returns></returns>
        public bool GetProperty_FoldVisible()
        {
            return (this.CategoryNodeStyle.FoldVisible && this.Alignment != SingleAccordionAlignments.Center);
        }

        /// <summary>
        /// 获取折叠图标左右外边距(根据显示状态、内容对齐方式)
        /// </summary>
        /// <returns></returns>
        public LRMargin GetProperty_FoldLRMargin()
        {
            return !this.GetProperty_FoldVisible() ? new LRMargin(0, 0) : new LRMargin((int)Math.Ceiling(this.CategoryNodeStyle.FoldLRMargin.Left * this.ScaleDpi), (int)Math.Ceiling(this.CategoryNodeStyle.FoldLRMargin.Right * this.ScaleDpi));
        }

        /// <summary>
        /// 获取折叠图标Size(根据显示状态、内容对齐方式)
        /// </summary>
        /// <returns></returns>
        public Size GetProperty_FoldSize()
        {
            return !GetProperty_FoldVisible() ? new Size(0, 0) : new Size((int)Math.Ceiling(this.CategoryNodeStyle.FoldSize.Width * this.ScaleDpi), (int)Math.Ceiling(this.CategoryNodeStyle.FoldSize.Height * this.ScaleDpi));
        }

        #endregion

        #region 公开方法

        /// <summary>
        /// 初始化控件内部元素布局
        /// </summary>
        public void InitializeElement()
        {
            if (initializeing)
                return;

            int border = this.BorderVisible ? 1 : 0;
            this.displayRectangle = new Rectangle(this.ClientRectangle.X + border, this.ClientRectangle.Y + border, this.ClientRectangle.Width - border * 2, this.ClientRectangle.Height - border * 2);
            this.UpdateRealityRectangle();
            this.UpdateAllNodeRectangle();
            this.UpdateScrollRectangle();
        }

        #endregion 

        #region 私有方法

        /// <summary>
        /// 更新菜单真实区Rect
        /// </summary>
        /// <returns></returns>
        internal void UpdateRealityRectangle()
        {
            int scale_label_node_height = (int)Math.Ceiling(this.LabelNodeStyle.Height * this.ScaleDpi);
            int scale_category_node_height = (int)Math.Ceiling(this.CategoryNodeStyle.Height * this.ScaleDpi);
            int scale_content_node_height = (int)Math.Ceiling(this.ContentNodeStyle.Height * this.ScaleDpi);

            int height = 0;
            foreach (SingleAccordionNode node in this.Nodes)
            {
                TBMargin node_TBMargin = this.GetProperty_TBMargin(node);
                height += node_TBMargin.Top;

                if (node is SingleAccordionLabelNode)
                {
                    height += scale_label_node_height;
                }
                else if (node is SingleAccordionCategoryNode)
                {
                    height += scale_category_node_height;

                    SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                    if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanded)
                    {
                        height += this.GetCategoryContainerHeight(category_node);
                    }
                    else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)//动画中
                    {
                        double progress = AnimationHelper.EaseOut(category_node.ECAnimationUsedTime, this.CategoryNodeStyle.ECAnimationAllTimer, 1.5);
                        if (progress > 1)
                        {
                            progress = 1;
                        }
                        if (progress < 0)
                        {
                            progress = 0;
                        }
                        height += (int)(this.GetCategoryContainerHeight(category_node) * progress);
                    }
                    else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)//动画中
                    {
                        double progress = AnimationHelper.EaseOut(this.CategoryNodeStyle.ECAnimationAllTimer - category_node.ECAnimationUsedTime, this.CategoryNodeStyle.ECAnimationAllTimer, 1.5);
                        if (progress > 1)
                        {
                            progress = 1;
                        }
                        if (progress < 0)
                        {
                            progress = 0;
                        }
                        height += (int)(this.GetCategoryContainerHeight(category_node) * progress);
                    }
                }
                else if (node is SingleAccordionContentNode)
                {
                    height += scale_content_node_height;
                }

                height += node_TBMargin.Bottom;
            }

            this.realityRectangle = new Rectangle(this.displayRectangle.X, this.displayRectangle.Y, this.displayRectangle.Width, height);

            int new_y = this.realityRectangle_Y;
            if (new_y < this.displayRectangle.Height - this.realityRectangle.Height)
            {
                new_y = this.displayRectangle.Height - this.realityRectangle.Height;
            }
            if (new_y > 0)
            {
                new_y = 0;
            }
            this.realityRectangle_Y = new_y;
        }

        /// <summary>
        /// 更新所有节点Rect
        /// </summary>
        internal void UpdateAllNodeRectangle()
        {
            int scale_lebel_node_height = (int)Math.Ceiling(this.LabelNodeStyle.Height * this.ScaleDpi);
            int scale_category_node_height = (int)Math.Ceiling(this.CategoryNodeStyle.Height * this.ScaleDpi);
            int scale_content_node_height = (int)Math.Ceiling(this.ContentNodeStyle.Height * this.ScaleDpi);

            int strat_y = this.realityRectangle.Y;
            foreach (SingleAccordionNode node in this.Nodes)
            {
                TBMargin node_TBMargin = this.GetProperty_TBMargin(node);
                strat_y += node_TBMargin.Top;

                if (node is SingleAccordionLabelNode)
                {
                    node.Rect = new Rectangle(this.realityRectangle.X, strat_y, this.realityRectangle.Width, scale_lebel_node_height);
                    strat_y += scale_lebel_node_height;
                }
                else if (node is SingleAccordionCategoryNode)
                {
                    node.Rect = new Rectangle(this.realityRectangle.X, strat_y, this.realityRectangle.Width, scale_category_node_height);
                    strat_y += scale_category_node_height;

                    SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                    int category_children_y = strat_y;
                    for (int k = 0; k < category_node.Childrens.Count; k++)
                    {
                        TBMargin content_TBMargin = this.GetProperty_TBMargin(category_node.Childrens[k]);
                        category_children_y += content_TBMargin.Top;
                        category_node.Childrens[k].Rect = new Rectangle(this.realityRectangle.X, category_children_y, this.realityRectangle.Width, scale_content_node_height);
                        category_children_y += scale_content_node_height;
                        category_children_y += content_TBMargin.Bottom;
                    }

                    int category_container_height = 0;
                    if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanded)
                    {
                        category_container_height = (category_children_y - strat_y);
                    }
                    else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseed)
                    {
                        category_container_height = 0;
                    }
                    else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)//动画中
                    {
                        double progress = AnimationHelper.EaseOut(category_node.ECAnimationUsedTime, this.CategoryNodeStyle.ECAnimationAllTimer, 1.5);
                        if (progress > 1)
                        {
                            progress = 1;
                        }
                        if (progress < 0)
                        {
                            progress = 0;
                        }
                        category_container_height = (int)((category_children_y - strat_y) * progress);
                    }
                    else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)//动画中
                    {
                        double progress = AnimationHelper.EaseOut(this.CategoryNodeStyle.ECAnimationAllTimer - category_node.ECAnimationUsedTime, this.CategoryNodeStyle.ECAnimationAllTimer, 1.5);
                        if (progress > 1)
                        {
                            progress = 1;
                        }
                        if (progress < 0)
                        {
                            progress = 0;
                        }
                        category_container_height = (int)((category_children_y - strat_y) * progress);
                    }

                    category_node.ContainerRect = new Rectangle(category_node.Rect.X, category_node.Rect.Bottom, category_node.Rect.Width, category_container_height);
                    strat_y += category_container_height;
                }
                else if (node is SingleAccordionContentNode)
                {
                    node.Rect = new Rectangle(this.realityRectangle.X, strat_y, this.realityRectangle.Width, scale_content_node_height);
                    strat_y += scale_content_node_height;
                }

                strat_y += node_TBMargin.Bottom;
            }

        }

        /// <summary>
        /// 更新滚动条Rect
        /// </summary>
        internal void UpdateScrollRectangle()
        {
            int scale_sliderThickness = (int)Math.Ceiling(this.ScrollBar.TrackThickness * this.ScaleDpi);
            int scale_thumbMinSize = (int)Math.Ceiling(ScrollBar.ThumbMinSize * this.ScaleDpi);

            this.ScrollBar.TrackRect = new Rectangle(this.displayRectangle.Right - scale_sliderThickness, this.displayRectangle.Y, scale_sliderThickness, this.displayRectangle.Height);

            int thumb_height = (int)Math.Max(Math.Min(this.ScrollBar.TrackRect.Height, scale_thumbMinSize), this.ScrollBar.TrackRect.Height * ((float)this.displayRectangle.Height / (float)this.realityRectangle.Height));
            int thumb_y = (int)(this.ScrollBar.TrackRect.Y + (this.ScrollBar.TrackRect.Height - thumb_height) * (-this.realityRectangle_Y / (float)(this.realityRectangle.Height - this.displayRectangle.Height)));
            this.ScrollBar.ThumbRect = new Rectangle(this.displayRectangle.Right - scale_sliderThickness, thumb_y, scale_sliderThickness, thumb_height);
        }

        /// <summary>
        /// 绘制标签节点
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="label_node">标签节点</param>
        /// <param name="commom_back_sb">标签节点背景画笔</param>
        /// <param name="commom_text_sb">标签节点文本画笔</param>>
        /// <param name="commom_splitterline_pen">分隔线画笔</param>
        /// <param name="font_metrics">字体信息</param>
        private void DrawLabelNode(Graphics g, SingleAccordionLabelNode label_node, SolidBrush commom_back_sb, SolidBrush commom_text_sb, Pen commom_splitterline_pen, NativeMethods.TEXTMETRIC font_metrics)
        {
            int scale_label_LRSlidingDistance = this.GetProperty_LRSlidingDistance(label_node);
            LRMargin scale_label_ImageLRMargin = this.GetProperty_NodeImageLRMargin(label_node);
            Size scale_label_ImageSize = this.GetProperty_NodeImageSize(label_node);
            LRMargin scale_label_TextLRMargin = this.GetProperty_TextLRMargin(label_node);

            commom_back_sb.Color = this.GetProperty_NodeBackColor(label_node);
            commom_text_sb.Color = this.GetProperty_NodeTextColor(label_node);
            commom_splitterline_pen.Color = this.GetProperty_NodeSplitterLineColor(label_node);

            Rectangle label_rect = new Rectangle(label_node.Rect.X, this.realityRectangle_Y + label_node.Rect.Y, label_node.Rect.Width, label_node.Rect.Height);
            Rectangle label_text_rect = this.GetNodeTextRectangleByAnimation(g, label_node, scale_label_LRSlidingDistance, scale_label_ImageLRMargin, scale_label_ImageSize, scale_label_TextLRMargin, font_metrics);
            Rectangle label_image_rect = new Rectangle((int)(this.Alignment == SingleAccordionAlignments.Right ? label_text_rect.Right + scale_label_TextLRMargin.Right + scale_label_ImageLRMargin.Left : label_text_rect.X - scale_label_TextLRMargin.Left - scale_label_ImageLRMargin.Right - scale_label_ImageSize.Width), (this.realityRectangle_Y + label_node.Rect.Y + (label_node.Rect.Height - scale_label_ImageSize.Height) / 2), scale_label_ImageSize.Width, scale_label_ImageSize.Height);
            Rectangle category_splitterline_rect = new Rectangle(label_node.Rect.X, this.realityRectangle_Y + label_node.Rect.Bottom - 1, label_node.Rect.Width, 1);

            g.SetClip(label_rect);

            SingleAccordionNodeDrawBeforeEventArgs node_before_arg = ((Events[EventNodeDrawBefore] as SingleAccordionNodeDrawBeforeEventHandler) != null) ? new SingleAccordionNodeDrawBeforeEventArgs(label_node, this.ScaleDpi, g, this.realityRectangle_Y, label_rect, commom_back_sb, this.GetProperty_NodeImageVisible(label_node), label_image_rect, this.GetProperty_Image(label_node), label_text_rect, commom_text_sb, false, Rectangle.Empty, 0, null, true, category_splitterline_rect, commom_splitterline_pen, false) : null;
            if (node_before_arg != null)
            {
                this.OnNodeDrawBefore(node_before_arg);
            }
            if (node_before_arg == null || node_before_arg.Cancel == false)
            {
                // 背景
                g.FillRectangle(commom_back_sb, label_rect);
                // 文本
                g.DrawString(label_node.Text, this.Font, commom_text_sb, label_text_rect.Location, StringFormat.GenericTypographic);
                // 图片
                if (this.GetProperty_NodeImageVisible(label_node) && this.GetProperty_Image(label_node) != null)
                {
                    g.DrawImage(this.GetProperty_Image(label_node), label_image_rect);
                }
                // 分隔线
                if (label_node.SplitterLineVisible)
                {
                    g.DrawLine(commom_splitterline_pen, label_node.Rect.X, this.realityRectangle_Y + label_node.Rect.Bottom - 1, label_node.Rect.Right, this.realityRectangle_Y + label_node.Rect.Bottom - 1);
                }
            }
            SingleAccordionNodeDrawAfterEventArgs node_after_arg = ((Events[EventNodeDrawAfter] as SingleAccordionNodeDrawAfterEventHandler) != null) ? new SingleAccordionNodeDrawAfterEventArgs(label_node, this.ScaleDpi, g, this.realityRectangle_Y, label_rect, commom_back_sb, this.GetProperty_NodeImageVisible(label_node), label_image_rect, this.GetProperty_Image(label_node), label_text_rect, commom_text_sb, false, Rectangle.Empty, 0, null, true, category_splitterline_rect, commom_splitterline_pen) : null;
            this.OnNodeDrawAfter(node_after_arg);

            g.ResetClip();
        }

        /// <summary>
        /// 绘制类别节点
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="category_node">类别节点</param>
        /// <param name="commom_back_sb">类别节点背景画笔</param>
        /// <param name="commom_text_sb">类别节点文本画笔</param>>
        /// <param name="commom_fold_pen">折叠图标画笔</param>
        /// <param name="commom_splitterline_pen">分隔线画笔</param>
        /// <param name="font_metrics">字体信息</param>
        private void DrawCategoryNode(Graphics g, SingleAccordionCategoryNode category_node, SolidBrush commom_back_sb, SolidBrush commom_text_sb, Pen commom_fold_pen, Pen commom_splitterline_pen, NativeMethods.TEXTMETRIC font_metrics)
        {
            int scale_category_LRSlidingDistance = this.GetProperty_LRSlidingDistance(category_node);
            LRMargin scale_category_FoldLRMargin = this.GetProperty_FoldLRMargin();
            Size scale_category_FoldSize = this.GetProperty_FoldSize();
            LRMargin scale_category_ImageLRMargin = this.GetProperty_NodeImageLRMargin(category_node);
            Size scale_category_ImageSize = this.GetProperty_NodeImageSize(category_node);
            LRMargin scale_category_TextLRMargin = this.GetProperty_TextLRMargin(category_node);

            commom_back_sb.Color = this.GetProperty_NodeBackColor(category_node);
            commom_text_sb.Color = this.GetProperty_NodeTextColor(category_node);
            commom_fold_pen.Color = this.GetProperty_NodeFoldColor(category_node);
            commom_splitterline_pen.Color = this.GetProperty_NodeSplitterLineColor(category_node);

            Rectangle category_rect = new Rectangle(category_node.Rect.X, this.realityRectangle_Y + category_node.Rect.Y, category_node.Rect.Width, category_node.Rect.Height);
            Rectangle category_text_rect = this.GetNodeTextRectangleByAnimation(g, category_node, scale_category_LRSlidingDistance, scale_category_ImageLRMargin, scale_category_ImageSize, scale_category_TextLRMargin, font_metrics);
            Rectangle category_image_rect = new Rectangle((int)(this.Alignment == SingleAccordionAlignments.Right ? category_text_rect.Right + scale_category_TextLRMargin.Right + scale_category_ImageLRMargin.Left : category_text_rect.X - scale_category_TextLRMargin.Left - scale_category_ImageLRMargin.Right - scale_category_ImageSize.Width), (this.realityRectangle_Y + category_node.Rect.Y + (category_node.Rect.Height - scale_category_ImageSize.Height) / 2), scale_category_ImageSize.Width, scale_category_ImageSize.Height);
            Rectangle category_flod_rect = new Rectangle((int)(this.Alignment == SingleAccordionAlignments.Right ? category_node.Rect.X + scale_category_FoldLRMargin.Left : category_node.Rect.Right - scale_category_FoldSize.Width - scale_category_FoldLRMargin.Right), (this.realityRectangle_Y + category_node.Rect.Y + (category_node.Rect.Height - scale_category_FoldSize.Height) / 2), scale_category_FoldSize.Width, scale_category_FoldSize.Height);
            int category_flod_angle = this.GetNodeExpandCollapseedFlodAngle(category_node);
            Rectangle category_splitterline_rect = new Rectangle(category_node.Rect.X, this.realityRectangle_Y + category_node.Rect.Bottom - 1, category_node.Rect.Width, 1);

            g.SetClip(category_rect);

            SingleAccordionNodeDrawBeforeEventArgs node_before_arg = ((Events[EventNodeDrawBefore] as SingleAccordionNodeDrawBeforeEventHandler) != null) ? new SingleAccordionNodeDrawBeforeEventArgs(category_node, this.ScaleDpi, g, this.realityRectangle_Y, category_rect, commom_back_sb, this.GetProperty_NodeImageVisible(category_node), category_image_rect, this.GetProperty_Image(category_node), category_text_rect, commom_text_sb, this.GetProperty_FoldVisible(), category_flod_rect, category_flod_angle, commom_fold_pen, true, category_splitterline_rect, commom_splitterline_pen, false) : null;
            if (node_before_arg != null)
            {
                this.OnNodeDrawBefore(node_before_arg);
            }
            if (node_before_arg == null || node_before_arg.Cancel == false)
            {
                // 背景
                g.FillRectangle(commom_back_sb, category_rect);
                // 文本
                g.DrawString(category_node.Text, this.Font, commom_text_sb, category_text_rect.Location, StringFormat.GenericTypographic);
                // 图片
                if (this.GetProperty_NodeImageVisible(category_node) && this.GetProperty_Image(category_node) != null)
                {
                    g.DrawImage(this.GetProperty_Image(category_node), category_image_rect);
                }
                // 展开折叠图标
                if (this.GetProperty_FoldVisible())
                {
                    float x_avg = category_flod_rect.Width / 4f;
                    float y_avg = category_flod_rect.Height / 4f;
                    commom_fold_pen.Width = x_avg * 6 / 9;

                    g.TranslateTransform(category_flod_rect.X + category_flod_rect.Width / 2, category_flod_rect.Y + category_flod_rect.Height / 2);
                    g.RotateTransform(category_flod_angle);
                    g.TranslateTransform(-(category_flod_rect.X + category_flod_rect.Width / 2), -(category_flod_rect.Y + category_flod_rect.Height / 2));

                    g.DrawLines(commom_fold_pen, new PointF[] { new PointF(category_flod_rect.X + x_avg * 3, category_flod_rect.Y), new PointF(category_flod_rect.X + x_avg, category_flod_rect.Y + y_avg * 2), new PointF(category_flod_rect.X + x_avg * 3, category_flod_rect.Bottom) });

                    g.ResetTransform();
                }
                // 分隔线
                if (category_node.SplitterLineVisible)
                {
                    g.DrawLine(commom_splitterline_pen, category_node.Rect.X, this.realityRectangle_Y + category_node.Rect.Bottom - 1, category_node.Rect.Right, this.realityRectangle_Y + category_node.Rect.Bottom - 1);
                }
            }
            SingleAccordionNodeDrawAfterEventArgs node_after_arg = ((Events[EventNodeDrawAfter] as SingleAccordionNodeDrawAfterEventHandler) != null) ? new SingleAccordionNodeDrawAfterEventArgs(category_node, this.ScaleDpi, g, this.realityRectangle_Y, category_rect, commom_back_sb, this.GetProperty_NodeImageVisible(category_node), category_image_rect, this.GetProperty_Image(category_node), category_text_rect, commom_text_sb, this.GetProperty_FoldVisible(), category_flod_rect, category_flod_angle, commom_fold_pen, true, category_splitterline_rect, commom_splitterline_pen) : null;
            this.OnNodeDrawAfter(node_after_arg);

            g.ResetClip();
        }

        /// <summary>
        /// 绘制内容节点
        /// </summary>
        /// <param name="g">画布</param>
        /// <param name="content_node">内容节点</param>
        /// <param name="commom_back_sb">内容节点背景画笔</param>
        /// <param name="commom_text_sb">内容节点文本画笔</param>>
        /// <param name="commom_splitterline_pen">分隔线画笔</param>
        /// <param name="font_metrics">字体信息</param>
        private void DrawContentNode(Graphics g, SingleAccordionContentNode content_node, SolidBrush commom_back_sb, SolidBrush commom_text_sb, Pen commom_splitterline_pen, NativeMethods.TEXTMETRIC font_metrics)
        {
            int scale_content_LRSlidingDistance = this.GetProperty_LRSlidingDistance(content_node);
            LRMargin scale_content_ImageLRMargin = this.GetProperty_NodeImageLRMargin(content_node);
            Size scale_content_ImageSize = this.GetProperty_NodeImageSize(content_node);
            LRMargin scale_content_TextLRMargin = this.GetProperty_TextLRMargin(content_node);

            commom_back_sb.Color = this.GetProperty_NodeBackColor(content_node);
            commom_text_sb.Color = this.GetProperty_NodeTextColor(content_node);
            commom_splitterline_pen.Color = this.GetProperty_NodeSplitterLineColor(content_node);

            Rectangle content_rect = new Rectangle(content_node.Rect.X, this.realityRectangle_Y + content_node.Rect.Y, content_node.Rect.Width, content_node.Rect.Height);
            Rectangle content_text_rect = this.GetNodeTextRectangleByAnimation(g, content_node, scale_content_LRSlidingDistance, scale_content_ImageLRMargin, scale_content_ImageSize, scale_content_TextLRMargin, font_metrics);
            Rectangle content_image_rect = new Rectangle((int)(this.Alignment == SingleAccordionAlignments.Right ? content_text_rect.Right + scale_content_TextLRMargin.Right + scale_content_ImageLRMargin.Left : content_text_rect.X - scale_content_TextLRMargin.Left - scale_content_ImageLRMargin.Right - scale_content_ImageSize.Width), (int)(this.realityRectangle_Y + content_node.Rect.Y + (content_node.Rect.Height - scale_content_ImageSize.Height) / 2), (int)scale_content_ImageSize.Width, (int)scale_content_ImageSize.Height);
            Rectangle category_splitterline_rect = new Rectangle(content_node.Rect.X, this.realityRectangle_Y + content_node.Rect.Bottom - 1, content_node.Rect.Width, 1);

            Rectangle clip_rect = new Rectangle(content_rect.X, content_rect.Y, content_rect.Width, content_rect.Height);
            if (content_node.Parent != null)
            {
                SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)content_node.Parent;
                clip_rect.Intersect(new Rectangle(category_node.ContainerRect.X, this.realityRectangle_Y + category_node.ContainerRect.Y, category_node.ContainerRect.Width, category_node.ContainerRect.Height));
            }
            g.SetClip(clip_rect);

            SingleAccordionNodeDrawBeforeEventArgs node_before_arg = ((Events[EventNodeDrawBefore] as SingleAccordionNodeDrawBeforeEventHandler) != null) ? new SingleAccordionNodeDrawBeforeEventArgs(content_node, this.ScaleDpi, g, this.realityRectangle_Y, content_rect, commom_back_sb, this.GetProperty_NodeImageVisible(content_node), content_image_rect, this.GetProperty_Image(content_node), content_text_rect, commom_text_sb, false, Rectangle.Empty, 0, null, true, category_splitterline_rect, commom_splitterline_pen, false) : null;
            if (node_before_arg != null)
            {
                this.OnNodeDrawBefore(node_before_arg);
            }
            if (node_before_arg == null || node_before_arg.Cancel == false)
            {
                // 背景
                g.FillRectangle(commom_back_sb, content_rect);
                // 文本
                g.DrawString(content_node.Text, this.Font, commom_text_sb, content_text_rect.Location, StringFormat.GenericTypographic);
                // 图片
                if (this.GetProperty_NodeImageVisible(content_node) && this.GetProperty_Image(content_node) != null)
                {
                    g.DrawImage(this.GetProperty_Image(content_node), content_image_rect);
                }
                // 分隔线
                if (content_node.SplitterLineVisible)
                {
                    g.DrawLine(commom_splitterline_pen, content_node.Rect.X, this.realityRectangle_Y + content_node.Rect.Bottom - 1, content_node.Rect.Right, this.realityRectangle_Y + content_node.Rect.Bottom - 1);
                }
            }

            SingleAccordionNodeDrawAfterEventArgs node_after_arg = ((Events[EventNodeDrawAfter] as SingleAccordionNodeDrawAfterEventHandler) != null) ? new SingleAccordionNodeDrawAfterEventArgs(content_node, this.ScaleDpi, g, this.realityRectangle_Y, content_rect, commom_back_sb, this.GetProperty_NodeImageVisible(content_node), content_image_rect, this.GetProperty_Image(content_node), content_text_rect, commom_text_sb, false, Rectangle.Empty, 0, null, true, category_splitterline_rect, commom_splitterline_pen) : null;
            this.OnNodeDrawAfter(node_after_arg);

            g.ResetClip();
        }

        /// <summary>
        /// 根据左右动画状态获获取节点文本Rectangle
        /// </summary>
        /// <param name="g"></param>
        /// <param name="node">节点</param>
        /// <param name="scale_category_LRSlidingDistance">左右滑动动画距离</param>
        /// <param name="scale_category_ImageLRMargin">图片外左右边距</param>
        /// <param name="scale_category_ImageSize">图片Size</param>
        /// <param name="scale_category_TextLRMargin">文本外左右边距</param>
        /// <param name="font_metrics">字体信息</param>
        /// <returns></returns>
        private Rectangle GetNodeTextRectangleByAnimation(Graphics g, SingleAccordionNode node, int scale_category_LRSlidingDistance, LRMargin scale_category_ImageLRMargin, Size scale_category_ImageSize, LRMargin scale_category_TextLRMargin, NativeMethods.TEXTMETRIC font_metrics)
        {
            Size node_text_size = new Size((int)Math.Ceiling(g.MeasureString(node.Text, this.Font, int.MaxValue, StringFormat.GenericTypographic).Width), font_metrics.GetFontRealHeight());
            int allTime = this.GetProperty_MouseAnimationAllTimer(node);
            float node_text_x = 0;
            switch (this.Alignment)
            {
                case SingleAccordionAlignments.Left:
                    {
                        if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeave)
                        {
                            node_text_x = node.Rect.X + scale_category_ImageLRMargin.Left + scale_category_ImageSize.Width + scale_category_ImageLRMargin.Right + scale_category_TextLRMargin.Left;
                        }
                        else if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEnter)
                        {
                            node_text_x = node.Rect.X + scale_category_ImageLRMargin.Left + scale_category_ImageSize.Width + scale_category_ImageLRMargin.Right + scale_category_TextLRMargin.Left + scale_category_LRSlidingDistance;
                        }
                        else if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                        {
                            node_text_x = node.Rect.X + scale_category_ImageLRMargin.Left + scale_category_ImageSize.Width + scale_category_ImageLRMargin.Right + scale_category_TextLRMargin.Left + (float)(scale_category_LRSlidingDistance * AnimationHelper.EaseOut(node.MouseAnimationUsedTime, allTime, 1.2));
                        }
                        else if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                        {
                            node_text_x = node.Rect.X + scale_category_ImageLRMargin.Left + scale_category_ImageSize.Width + scale_category_ImageLRMargin.Right + scale_category_TextLRMargin.Left + (float)(scale_category_LRSlidingDistance * AnimationHelper.EaseOut((allTime - node.MouseAnimationUsedTime), allTime, 1.2));
                        }
                        break;
                    }
                case SingleAccordionAlignments.Center:
                    {
                        node_text_x = node.Rect.X + (node.Rect.Width - node_text_size.Width) / 2f;
                        break;
                    }
                case SingleAccordionAlignments.Right:
                    {
                        if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeave)
                        {
                            node_text_x = node.Rect.Right - scale_category_ImageLRMargin.Left - scale_category_ImageSize.Width - scale_category_ImageLRMargin.Right - scale_category_TextLRMargin.Right - node_text_size.Width;
                        }
                        else if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEnter)
                        {
                            node_text_x = node.Rect.Right - scale_category_ImageLRMargin.Left - scale_category_ImageSize.Width - scale_category_ImageLRMargin.Right - scale_category_TextLRMargin.Right - node_text_size.Width - scale_category_LRSlidingDistance;
                        }
                        else if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                        {
                            node_text_x = node.Rect.Right - scale_category_ImageLRMargin.Left - scale_category_ImageSize.Width - scale_category_ImageLRMargin.Right - scale_category_TextLRMargin.Right - node_text_size.Width - (float)(scale_category_LRSlidingDistance * AnimationHelper.EaseOut(node.MouseAnimationUsedTime, allTime, 1.2));
                        }
                        else if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                        {
                            node_text_x = node.Rect.Right - scale_category_ImageLRMargin.Left - scale_category_ImageSize.Width - scale_category_ImageLRMargin.Right - scale_category_TextLRMargin.Right - node_text_size.Width - (float)(scale_category_LRSlidingDistance * AnimationHelper.EaseOut((allTime - node.MouseAnimationUsedTime), allTime, 1.2));
                        }
                        break;
                    }
            }

            return new Rectangle((int)node_text_x, this.realityRectangle_Y + node.Rect.Y + (node.Rect.Height - node_text_size.Height) / 2, node_text_size.Width, node_text_size.Height);

        }

        /// <summary>
        /// 获取类别节点容器高度
        /// </summary>
        /// <param name="category_node">类别节点</param>
        /// <returns></returns>
        private int GetCategoryContainerHeight(SingleAccordionCategoryNode category_node)
        {
            int scale_content_node_height = (int)Math.Ceiling(this.ContentNodeStyle.Height * this.ScaleDpi);
            int height = 0;
            for (int k = 0; k < category_node.Childrens.Count; k++)
            {
                TBMargin content_TBMargin = this.GetProperty_TBMargin(category_node.Childrens[k]);
                height += (content_TBMargin.Top + scale_content_node_height + content_TBMargin.Bottom);
            }
            return height;
        }

        /// <summary>
        /// 获取类别节点展开折叠图标旋转角度
        /// </summary>
        /// <param name="category_node">类别节点</param>
        /// <returns></returns>
        private int GetNodeExpandCollapseedFlodAngle(SingleAccordionCategoryNode category_node)
        {
            if (this.Alignment == SingleAccordionAlignments.Center)
                return 0;

            bool isinner = (this.Alignment == SingleAccordionAlignments.Left && this.CategoryNodeStyle.FoldArrowsIsInward) || (this.Alignment == SingleAccordionAlignments.Right && !this.CategoryNodeStyle.FoldArrowsIsInward);

            if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseed)
            {
                if (isinner)
                    return 0;
                else
                    return 180;
            }
            else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Collapseing)
            {
                if (isinner)
                    return (int)(-90 * (1 - (category_node.ECAnimationUsedTime / (float)this.CategoryNodeStyle.ECAnimationAllTimer)));
                else
                    return (int)(180 + 90 * (1 - (category_node.ECAnimationUsedTime / (float)this.CategoryNodeStyle.ECAnimationAllTimer)));
            }
            else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanded)
            {
                if (isinner)
                    return -90;
                else
                    return 270;
            }
            else if (category_node.ECAnimationStatus == SingleAccordionNodeECAnimationStatuss.Expanding)
            {
                if (isinner)
                    return (int)(-90 * (category_node.ECAnimationUsedTime / (float)this.CategoryNodeStyle.ECAnimationAllTimer));
                else
                    return (int)(180 + 90 * (category_node.ECAnimationUsedTime / (float)this.CategoryNodeStyle.ECAnimationAllTimer));
            }

            return 0;
        }

        /// <summary>
        /// 查找并添加符合条件的节点到鼠标动画中
        /// </summary>
        /// <param name="mousePoint">这是鼠标坐标</param>
        internal void AddNodeMouseAnimation(Point mousePoint)
        {
            if (this.Alignment == SingleAccordionAlignments.Center || this.mousedownType != -1)
                return;

            Point reality_mousePoint = new Point(mousePoint.X, -this.realityRectangle_Y + mousePoint.Y);

            bool isInArea = this.displayRectangle.Contains(mousePoint) && (!this.GetScrollVisible() || reality_mousePoint.X < this.ScrollBar.TrackRect.X);
            foreach (SingleAccordionNode node in this.Nodes)
            {
                if (this.GetProperty_MouseAnimationEnabled(node))
                {
                    if (isInArea && node.Rect.Contains(reality_mousePoint))
                    {
                        if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeave || node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                        {
                            if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                            {
                                node.MouseAnimationUsedTime = node.GetMouseAnimationAllTime() - node.MouseAnimationUsedTime;
                            }
                            node.MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseEntering;
                            this.mouseAnimationList.Add(node);
                        }
                    }
                    else
                    {
                        if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEnter || node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                        {
                            if (node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                            {
                                node.MouseAnimationUsedTime = node.GetMouseAnimationAllTime() - node.MouseAnimationUsedTime;
                            }
                            node.MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing;
                            this.mouseAnimationList.Add(node);
                        }
                    }
                }
                if (node is SingleAccordionCategoryNode)
                {
                    SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                    foreach (SingleAccordionContentNode content_node in category_node.Childrens)
                    {
                        if (this.GetProperty_MouseAnimationEnabled(content_node))
                        {
                            if (isInArea && category_node.ContainerRect.Contains(reality_mousePoint) && content_node.Rect.Contains(reality_mousePoint))
                            {
                                if (content_node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeave || content_node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                                {
                                    if (content_node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing)
                                    {
                                        content_node.MouseAnimationUsedTime = content_node.GetMouseAnimationAllTime() - content_node.MouseAnimationUsedTime;
                                    }
                                    content_node.MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseEntering;
                                    this.mouseAnimationList.Add(content_node);
                                }
                            }
                            else
                            {
                                if (content_node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEnter || content_node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                                {
                                    if (content_node.MouseAnimationStatus == SingleAccordionNodeMouseAnimationStatuss.MouseEntering)
                                    {
                                        content_node.MouseAnimationUsedTime = content_node.GetMouseAnimationAllTime() - content_node.MouseAnimationUsedTime;
                                    }
                                    content_node.MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseLeaveing;
                                    this.mouseAnimationList.Add(content_node);
                                }
                            }
                        }
                    }
                }
            }
            this.IntervalTimerStop();
            this.IntervalTimerStart();
        }

        /// <summary>
        /// 查找并移除符合条件的节点从鼠标动画中
        /// </summary>
        internal void RemoveNodeMouseAnimation()
        {
            if (this.mouseAnimationList.Count < 1)
                return;

            List<SingleAccordionNode> tmp = new List<SingleAccordionNode>();
            for (int i = 0; i < this.mouseAnimationList.Count; i++)
            {
                if (this.Alignment == SingleAccordionAlignments.Center || !this.GetProperty_MouseAnimationEnabled(this.mouseAnimationList[i]))
                {
                    tmp.Add(this.mouseAnimationList[i]);
                }
            }

            if (tmp.Count > 0)
            {
                for (int i = 0; i < tmp.Count; i++)
                {
                    SingleAccordionNode node = tmp[i];
                    node.MouseAnimationStatus = SingleAccordionNodeMouseAnimationStatuss.MouseLeave;
                    node.MouseAnimationUsedTime = 0;
                    this.mouseAnimationList.Remove(node);
                }
                this.IntervalTimerStop();
                this.Invalidate();
            }
        }

        /// <summary>
        /// 开始动画计时器
        /// </summary>
        private void IntervalTimerStart()
        {
            if (this.mouseAnimationList.Count > 0 || this.ecAnimationList.Count > 0 || this.customAnimationList.Count > 0)
            {
                MainThreadAnimationControl.AnimationStart(this);
            }
        }

        /// <summary>
        /// 停止动画计时器
        /// </summary>
        private void IntervalTimerStop()
        {
            if (this.mouseAnimationList.Count < 1 && this.ecAnimationList.Count < 1 && this.customAnimationList.Count < 1)
            {
                MainThreadAnimationControl.AnimationStop(this);
            }
        }

        /// <summary>
        /// 获取滚动条显示状态
        /// </summary>
        /// <returns></returns>
        private bool GetScrollVisible()
        {
            return (this.realityRectangle.Height > this.displayRectangle.Height);
        }

        /// <summary>
        /// 滚动条命中测试（设计器使用）
        /// </summary>
        /// <param name="control_point">坐标(相对于控件)</param>
        /// <returns>返回是否在滚动条区域中</returns>
        internal bool HitTestSroll(Point control_point)
        {
            return this.GetScrollVisible() && this.ScrollBar.TrackRect.Contains(control_point);
        }

        /// <summary>
        /// 类别节点命中测试（设计器使用）
        /// </summary>
        /// <param name="control_point">坐标(相对于控件)</param>
        /// <returns></returns>
        internal SingleAccordionCategoryNode HitTestCategoryNode(Point control_point)
        {
            if (this.displayRectangle.Contains(control_point))
            {
                Point reality_mousePoint = new Point(control_point.X, -this.realityRectangle_Y + control_point.Y);
                foreach (SingleAccordionNode node in this.Nodes)
                {
                    if (node is SingleAccordionCategoryNode)
                    {
                        SingleAccordionCategoryNode category_node = (SingleAccordionCategoryNode)node;
                        if (category_node.Rect.Top <= reality_mousePoint.Y && reality_mousePoint.Y <= category_node.Rect.Bottom)
                        {
                            return category_node;
                        }
                    }
                }
            }
            return null;
        }

        #endregion

        #region 类

        [TypeConverter(typeof(PropertyOrderConverter))]
        public class CategoryNodeStyleObject
        {
            private SingleAccordion owner = null;
            internal CategoryNodeStyleObject(SingleAccordion owner) { this.owner = owner; }

            #region 属性

            private int ecAnimationAllTimer = 150;
            /// <summary>
            /// 展开折叠动画总时间(毫秒)
            /// </summary>
            [Description("展开折叠动画总时间(毫秒)")]
            [PropertyOrder(-200)]
            [DefaultValue(150)]
            public int ECAnimationAllTimer
            {
                get { return this.ecAnimationAllTimer; }
                set
                {
                    if (value < 0)
                        value = 0;
                    if (this.ecAnimationAllTimer == value)
                        return;

                    this.ecAnimationAllTimer = value;
                }
            }

            private bool mouseAnimationEnabled = false;
            /// <summary>
            /// 是否启用节点鼠标动画
            /// </summary>
            [Description("是否启用节点鼠标动画")]
            [PropertyOrder(-196)]
            [DefaultValue(false)]
            public bool MouseAnimationEnabled
            {
                get { return this.mouseAnimationEnabled; }
                set
                {
                    if (this.mouseAnimationEnabled == value)
                        return;

                    this.mouseAnimationEnabled = value;
                    if (!value && this.owner != null)
                    {
                        this.owner.RemoveNodeMouseAnimation();
                    }
                }
            }

            private int mouseAnimationAllTimer = 150;
            /// <summary>
            /// 鼠标动画总时间(毫秒)
            /// </summary>
            [Description("鼠标动画总时间(毫秒)")]
            [PropertyOrder(-190)]
            [DefaultValue(150)]
            public int MouseAnimationAllTimer
            {
                get { return this.mouseAnimationAllTimer; }
                set
                {
                    if (value < 0)
                        value = 0;
                    if (this.mouseAnimationAllTimer == value)
                        return;

                    this.mouseAnimationAllTimer = value;
                }
            }

            private int lRAnimationDistance = 0;
            /// <summary>
            /// 左右滑动动画距离
            /// </summary>
            [Description("左右滑动动画距离")]
            [PropertyOrder(-188)]
            [DefaultValue(0)]
            public int LRAnimationDistance
            {
                get { return this.lRAnimationDistance; }
                set
                {
                    if (this.lRAnimationDistance == value || value < 0)
                        return;

                    this.lRAnimationDistance = value;
                }
            }

            private int height = 30;
            /// <summary>
            /// 高度
            /// </summary>
            [Description("高度")]
            [PropertyOrder(-186)]
            [DefaultValue(30)]
            public int Height
            {
                get { return this.height; }
                set
                {
                    if (this.height == value || value <= 0)
                        return;

                    this.height = value;
                    if (this.owner != null)
                    {
                        this.owner.UpdateRealityRectangle();
                        this.owner.UpdateAllNodeRectangle();
                        this.owner.UpdateScrollRectangle();
                        this.owner.Invalidate();
                    }
                }
            }

            private TBMargin tBMargin = new TBMargin(0, 0);
            /// <summary>
            /// 上下外边距
            /// </summary>
            [Description("上下外边距")]
            [PropertyOrder(-185)]
            [DefaultValue(typeof(TBMargin), "0,0")]
            public TBMargin TBMargin
            {
                get { return this.tBMargin; }
                set
                {
                    if (value.Top < -1)
                        value.Top = -1;
                    if (value.Bottom < -1)
                        value.Bottom = -1;
                    if (this.tBMargin == value)
                        return;

                    this.tBMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.UpdateRealityRectangle();
                        this.owner.UpdateAllNodeRectangle();
                        this.owner.UpdateScrollRectangle();
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin textLRMargin = new LRMargin(4, 4);
            /// <summary>
            /// 文本左右外边距
            /// </summary>
            [Description("文本左右外边距")]
            [PropertyOrder(-184)]
            [DefaultValue(typeof(LRMargin), "4, 4")]
            public LRMargin TextLRMargin
            {
                get { return this.textLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.textLRMargin == value)
                        return;

                    this.textLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private bool imageVisible = false;
            /// <summary>
            /// 是否显示图片
            /// </summary>
            [Description("是否显示图片")]
            [PropertyOrder(-160)]
            [DefaultValue(false)]
            public bool ImageVisible
            {
                get { return this.imageVisible; }
                set
                {
                    if (this.imageVisible == value)
                        return;

                    this.imageVisible = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin imageLRMargin = new LRMargin(4, 14);
            /// <summary>
            /// 图片左右外边距
            /// </summary>
            [Description("图片左右外边距")]
            [PropertyOrder(-158)]
            [DefaultValue(typeof(LRMargin), "4, 14")]
            public LRMargin ImageLRMargin
            {
                get { return this.imageLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.imageLRMargin == value)
                        return;

                    this.imageLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Size imageSize = new Size(14, 14);
            /// <summary>
            /// 图片Size
            /// </summary>
            [Description("图片Size")]
            [PropertyOrder(-156)]
            [DefaultValue(typeof(Size), "14, 14")]
            public Size ImageSize
            {
                get { return this.imageSize; }
                set
                {
                    if (this.imageSize == value || value.Width <= 0 || value.Height < 0)
                        return;

                    this.imageSize = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Image image = null;
            /// <summary>
            /// 图片(通用)
            /// </summary>
            [Description("图片(通用)")]
            [PropertyOrder(-154)]
            [DefaultValue(null)]
            [RefreshProperties(RefreshProperties.Repaint)]
            public Image Image
            {
                get { return this.image; }
                set
                {
                    if (this.image == value)
                        return;

                    this.image = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private bool foldVisible = true;
            /// <summary>
            /// 是否显示折叠图标
            /// </summary>
            [Description("是否显示折叠图标")]
            [PropertyOrder(-140)]
            [DefaultValue(true)]
            public bool FoldVisible
            {
                get { return this.foldVisible; }
                set
                {
                    if (this.foldVisible == value)
                        return;

                    this.foldVisible = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin foldLRMargin = new LRMargin(4, 14);
            /// <summary>
            /// 折叠按钮左右外边距
            /// </summary>
            [Description("折叠按钮左右外边距")]
            [PropertyOrder(-138)]
            [DefaultValue(typeof(LRMargin), "4, 14")]
            public LRMargin FoldLRMargin
            {
                get { return this.foldLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.foldLRMargin == value)
                        return;

                    this.foldLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Size foldSize = new Size(11, 11);
            /// <summary>
            /// 折叠图标Size
            /// </summary>
            [Description("折叠图标Size")]
            [PropertyOrder(-136)]
            [DefaultValue(typeof(Size), "11,11")]
            public Size FoldSize
            {
                get { return this.foldSize; }
                set
                {
                    if (this.foldSize == value || value.Width <= 0 || value.Height < 0)
                        return;

                    this.foldSize = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private bool foldArrowsIsInward = true;
            /// <summary>
            /// 折叠箭头方向是否往内
            /// </summary>
            [Description("折叠箭头方向是否往内")]
            [PropertyOrder(-134)]
            [DefaultValue(true)]
            public bool FoldArrowsIsInward
            {
                get { return this.foldArrowsIsInward; }
                set
                {
                    if (this.foldArrowsIsInward == value)
                        return;

                    this.foldArrowsIsInward = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            #endregion

        }

        [TypeConverter(typeof(PropertyOrderConverter))]
        public class ContentNodeStyleObject
        {
            private SingleAccordion owner = null;
            internal ContentNodeStyleObject(SingleAccordion owner) { this.owner = owner; }

            #region 属性

            private bool mouseAnimationEnabled = true;
            /// <summary>
            /// 是否启用节点鼠标动画
            /// </summary>
            [Description("是否启用节点鼠标动画")]
            [PropertyOrder(-196)]
            [DefaultValue(true)]
            public bool MouseAnimationEnabled
            {
                get { return this.mouseAnimationEnabled; }
                set
                {
                    if (this.mouseAnimationEnabled == value)
                        return;

                    this.mouseAnimationEnabled = value;
                    if (!value && this.owner != null)
                    {
                        this.owner.RemoveNodeMouseAnimation();
                    }
                }
            }

            private int mouseAnimationAllTimer = 150;
            /// <summary>
            /// 鼠标动画总时间(毫秒)
            /// </summary>
            [Description("鼠标动画总时间(毫秒)")]
            [PropertyOrder(-190)]
            [DefaultValue(150)]
            public int MouseAnimationAllTimer
            {
                get { return this.mouseAnimationAllTimer; }
                set
                {
                    if (value < 0)
                        value = 0;
                    if (this.mouseAnimationAllTimer == value)
                        return;

                    this.mouseAnimationAllTimer = value;
                }
            }

            private int lRAnimationDistance = 10;
            /// <summary>
            /// 左右滑动动画距离
            /// </summary>
            [Description("左右滑动动画距离")]
            [PropertyOrder(-188)]
            [DefaultValue(10)]
            public int LRAnimationDistance
            {
                get { return this.lRAnimationDistance; }
                set
                {
                    if (this.lRAnimationDistance == value || value < 0)
                        return;

                    this.lRAnimationDistance = value;
                }
            }

            private int height = 30;
            /// <summary>
            /// 高度
            /// </summary>
            [Description("高度")]
            [PropertyOrder(-186)]
            [DefaultValue(30)]
            public int Height
            {
                get { return this.height; }
                set
                {
                    if (this.height == value || value <= 0)
                        return;

                    this.height = value;
                    if (this.owner != null)
                    {
                        this.owner.UpdateRealityRectangle();
                        this.owner.UpdateAllNodeRectangle();
                        this.owner.UpdateScrollRectangle();
                        this.owner.Invalidate();
                    }
                }
            }

            private TBMargin tBMargin = new TBMargin(0, 0);
            /// <summary>
            /// 上下外边距
            /// </summary>
            [Description("上下外边距")]
            [PropertyOrder(-185)]
            [DefaultValue(typeof(TBMargin), "0,0")]
            public TBMargin TBMargin
            {
                get { return this.tBMargin; }
                set
                {
                    if (value.Top < -1)
                        value.Top = -1;
                    if (value.Bottom < -1)
                        value.Bottom = -1;
                    if (this.tBMargin == value)
                        return;

                    this.tBMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.UpdateRealityRectangle();
                        this.owner.UpdateAllNodeRectangle();
                        this.owner.UpdateScrollRectangle();
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin textLRMargin = new LRMargin(4, 4);
            /// <summary>
            /// 文本左右外边距
            /// </summary>
            [Description("文本左右外边距")]
            [PropertyOrder(-184)]
            [DefaultValue(typeof(LRMargin), "4, 4")]
            public LRMargin TextLRMargin
            {
                get { return this.textLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.textLRMargin == value)
                        return;

                    this.textLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private bool imageVisible = false;
            /// <summary>
            /// 是否显示图片
            /// </summary>
            [Description("是否显示图片")]
            [PropertyOrder(-160)]
            [DefaultValue(false)]
            public bool ImageVisible
            {
                get { return this.imageVisible; }
                set
                {
                    if (this.imageVisible == value)
                        return;

                    this.imageVisible = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin imageLRMargin = new LRMargin(4, 14);
            /// <summary>
            /// 图片左右外边距
            /// </summary>
            [Description("图片左右外边距")]
            [PropertyOrder(-158)]
            [DefaultValue(typeof(LRMargin), "4, 14")]
            public LRMargin ImageLRMargin
            {
                get { return this.imageLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.imageLRMargin == value)
                        return;

                    this.imageLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Size imageSize = new Size(14, 14);
            /// <summary>
            /// 图片Size
            /// </summary>
            [Description("图片Size")]
            [PropertyOrder(-156)]
            [DefaultValue(typeof(Size), "14,14")]
            public Size ImageSize
            {
                get { return this.imageSize; }
                set
                {
                    if (value.Width < 0)
                        value.Width = 0;
                    if (value.Height < 0)
                        value.Height = 0;
                    if (this.imageSize == value)
                        return;

                    this.imageSize = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Image image = null;
            /// <summary>
            /// 图片(通用)
            /// </summary>
            [Description("图片(通用)")]
            [PropertyOrder(-154)]
            [DefaultValue(null)]
            [RefreshProperties(RefreshProperties.Repaint)]
            public Image Image
            {
                get { return this.image; }
                set
                {
                    if (this.image == value)
                        return;

                    this.image = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            #endregion

        }

        [TypeConverter(typeof(PropertyOrderConverter))]
        public class LabelNodeStyleObject
        {
            private SingleAccordion owner = null;
            internal LabelNodeStyleObject(SingleAccordion owner) { this.owner = owner; }

            #region 属性

            private bool mouseAnimationEnabled = false;
            /// <summary>
            /// 是否启用节点鼠标动画
            /// </summary>
            [Description("是否启用节点鼠标动画")]
            [PropertyOrder(-196)]
            [DefaultValue(false)]
            public bool MouseAnimationEnabled
            {
                get { return this.mouseAnimationEnabled; }
                set
                {
                    if (this.mouseAnimationEnabled == value)
                        return;

                    this.mouseAnimationEnabled = value;
                    if (!value && this.owner != null)
                    {
                        this.owner.RemoveNodeMouseAnimation();
                    }
                }
            }

            private int mouseAnimationAllTimer = 150;
            /// <summary>
            /// 鼠标动画总时间(毫秒)
            /// </summary>
            [Description("鼠标动画总时间(毫秒)")]
            [PropertyOrder(-190)]
            [DefaultValue(150)]
            public int MouseAnimationAllTimer
            {
                get { return this.mouseAnimationAllTimer; }
                set
                {
                    if (value < 0)
                        value = 0;
                    if (this.mouseAnimationAllTimer == value)
                        return;

                    this.mouseAnimationAllTimer = value;
                }
            }

            private int lRAnimationDistance = 0;
            /// <summary>
            /// 左右滑动动画距离
            /// </summary>
            [Description("左右滑动动画距离")]
            [PropertyOrder(-188)]
            [DefaultValue(0)]
            public int LRAnimationDistance
            {
                get { return this.lRAnimationDistance; }
                set
                {
                    if (this.lRAnimationDistance == value || value < 0)
                        return;

                    this.lRAnimationDistance = value;
                }
            }

            private int height = 30;
            /// <summary>
            /// 高度
            /// </summary>
            [Description("高度")]
            [PropertyOrder(-186)]
            [DefaultValue(30)]
            public int Height
            {
                get { return this.height; }
                set
                {
                    if (this.height == value || value <= 0)
                        return;

                    this.height = value;
                    if (this.owner != null)
                    {
                        this.owner.UpdateRealityRectangle();
                        this.owner.UpdateAllNodeRectangle();
                        this.owner.UpdateScrollRectangle();
                        this.owner.Invalidate();
                    }
                }
            }

            private TBMargin tBMargin = new TBMargin(0, 0);
            /// <summary>
            /// 上下外边距
            /// </summary>
            [Description("上下外边距")]
            [PropertyOrder(-185)]
            [DefaultValue(typeof(TBMargin), "0,0")]
            public TBMargin TBMargin
            {
                get { return this.tBMargin; }
                set
                {
                    if (value.Top < -1)
                        value.Top = -1;
                    if (value.Bottom < -1)
                        value.Bottom = -1;
                    if (this.tBMargin == value)
                        return;

                    this.tBMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.UpdateRealityRectangle();
                        this.owner.UpdateAllNodeRectangle();
                        this.owner.UpdateScrollRectangle();
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin textLRMargin = new LRMargin(4, 4);
            /// <summary>
            /// 文本左右外边距
            /// </summary>
            [Description("文本左右外边距")]
            [PropertyOrder(-184)]
            [DefaultValue(typeof(LRMargin), "4, 4")]
            public LRMargin TextLRMargin
            {
                get { return this.textLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.textLRMargin == value)
                        return;

                    this.textLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private bool imageVisible = false;
            /// <summary>
            /// 是否显示图片
            /// </summary>
            [Description("是否显示图片")]
            [PropertyOrder(-160)]
            [DefaultValue(false)]
            public bool ImageVisible
            {
                get { return this.imageVisible; }
                set
                {
                    if (this.imageVisible == value)
                        return;

                    this.imageVisible = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private LRMargin imageLRMargin = new LRMargin(4, 14);
            /// <summary>
            /// 图片左右外边距
            /// </summary>
            [Description("图片左右外边距")]
            [PropertyOrder(-158)]
            [DefaultValue(typeof(LRMargin), "4, 14")]
            public LRMargin ImageLRMargin
            {
                get { return this.imageLRMargin; }
                set
                {
                    if (value.Left < 0)
                        value.Left = 0;
                    if (value.Right < 0)
                        value.Right = 0;
                    if (this.imageLRMargin == value)
                        return;

                    this.imageLRMargin = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Size imageSize = new Size(14, 14);
            /// <summary>
            /// 图片Size
            /// </summary>
            [Description("图片Size")]
            [PropertyOrder(-156)]
            [DefaultValue(typeof(Size), "14,14")]
            public Size ImageSize
            {
                get { return this.imageSize; }
                set
                {
                    if (this.imageSize == value || value.Width <= 0 || value.Height < 0)
                        return;

                    this.imageSize = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private Image image = null;
            /// <summary>
            /// 图片(通用)
            /// </summary>
            [Description("图片(通用)")]
            [PropertyOrder(-154)]
            [DefaultValue(null)]
            [RefreshProperties(RefreshProperties.Repaint)]
            public Image Image
            {
                get { return this.image; }
                set
                {
                    if (this.image == value)
                        return;

                    this.image = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            #endregion

        }

        [TypeConverter(typeof(PropertyOrderConverter))]
        public class ScrollBarObject
        {
            private SingleAccordion owner = null;
            internal ScrollBarObject(SingleAccordion owner) { this.owner = owner; }

            #region 属性

            private bool thumbRoundEnabled = false;
            /// <summary>
            /// 拇指是否为圆角
            /// </summary>
            [Description("滑块是否为圆角")]
            [PropertyOrder(-198)]
            [DefaultValue(false)]
            public bool ThumbRoundEnabled
            {
                get { return this.thumbRoundEnabled; }
                set
                {
                    if (this.thumbRoundEnabled == value)
                        return;

                    this.thumbRoundEnabled = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private int trackThickness = 12;
            /// <summary>
            /// 轨道厚度
            /// </summary>
            [Description("轨道厚度")]
            [PropertyOrder(-198)]
            [DefaultValue(12)]
            public int TrackThickness
            {
                get { return this.trackThickness; }
                set
                {
                    if (this.trackThickness == value || value < 0)
                        return;

                    this.trackThickness = value;
                    this.owner.UpdateScrollRectangle();
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private int thumbMinSize = 26;
            /// <summary>
            /// 拇指最小高度
            /// </summary>
            [Description("拇指最小高度")]
            [PropertyOrder(-192)]
            [DefaultValue(26)]
            public int ThumbMinSize
            {
                get { return this.thumbMinSize; }
                set
                {
                    if (this.thumbMinSize == value || value < 1)
                        return;

                    this.thumbMinSize = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            private bool autoHide = false;
            /// <summary>
            ///是否自动隐藏
            /// </summary>
            [Description("是否自动隐藏")]
            [PropertyOrder(-190)]
            [DefaultValue(false)]
            public bool AutoHide
            {
                get { return this.autoHide; }
                set
                {
                    if (this.autoHide == value)
                        return;

                    this.autoHide = value;
                    if (this.owner != null)
                    {
                        this.owner.Invalidate();
                    }
                }
            }

            /// <summary>
            /// 鼠标是否已进入
            /// </summary>
            [Browsable(false)]
            public bool IsMouseEnter
            {
                get { return this.owner.IsMouseEnter(this); }
            }

            /// <summary>
            /// 轨道Rect
            /// </summary>
            [Browsable(false)]
            [EditorBrowsable(EditorBrowsableState.Never)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
            public Rectangle TrackRect { get; set; }

            /// <summary>
            /// 拇指rect
            /// </summary>
            [Browsable(false)]
            [EditorBrowsable(EditorBrowsableState.Never)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
            public Rectangle ThumbRect { get; set; }

            #endregion

        }

        #endregion

        #region 外观

        public class StyleAppearanceObject : AppearanceObjectBase
        {
            internal StyleAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

            #region 属性

            private Color skinBorderColor = Color.Empty;
            private readonly Color defaultBorderColor = SystemColors.ActiveCaption;
            private Color borderColor = Color.Empty;
            /// <summary>
            /// 边框颜色
            /// </summary>
            [Description("边框颜色")]
            [PropertyOrder(-198)]
            [SkinProperty(true, false)]
            public Color BorderColor
            {
                get
                {
                    if (this.owner.GetSkinObjectSkinStateCore())
                    {
                        return this.skinBorderColor;
                    }

                    if (this.borderColor != Color.Empty)
                    {
                        return this.borderColor;
                    }

                    return this.defaultBorderColor;
                }
                set
                {
                    if (this.borderColor == value)
                        return;

                    this.borderColor = value;
                    this.Invalidate();
                }
            }
            private bool ShouldSerializeBorderColor()
            {
                return this.borderColor != Color.Empty;
            }
            private void ResetBorderColor()
            {
                this.borderColor = Color.Empty;
                this.Invalidate();
            }

            private Color skinBackColor = Color.Empty;
            private readonly Color defaultBackColor = SystemColors.Control;
            private Color backColor = Color.Empty;
            /// <summary>
            /// 背景颜色
            /// </summary>
            [Description("背景颜色")]
            [PropertyOrder(-195)]
            [SkinProperty(true, true)]
            public Color BackColor
            {
                get
                {
                    if (this.owner.GetSkinObjectSkinStateCore() && this.skinBackColor != Color.Empty)
                    {
                        return this.skinBackColor;
                    }

                    if (this.backColor != Color.Empty)
                    {
                        return this.backColor;
                    }

                    if (((Control)this.owner).Parent != null)
                    {
                        return ((Control)this.owner).Parent.BackColor;
                    }

                    return this.defaultBackColor;
                }
                set
                {
                    if (this.backColor == value)
                        return;

                    this.backColor = value;
                    this.Invalidate();
                }
            }
            private bool ShouldSerializeBackColor()
            {
                return this.backColor != Color.Empty;
            }
            private void ResetBackColor()
            {
                this.backColor = Color.Empty;
                this.Invalidate();
            }

            private LabelNodeAppearanceObject labelNode;
            /// <summary>
            /// 标签节点
            /// </summary>
            [Description("标签节点")]
            [PropertyOrder(-192)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public LabelNodeAppearanceObject LabelNode
            {
                get
                {
                    if (this.labelNode == null)
                        this.labelNode = new LabelNodeAppearanceObject(this.owner, this);
                    return this.labelNode;
                }
            }

            private CategoryNodeAppearanceObject categoryNode;
            /// <summary>
            /// 类别节点
            /// </summary>
            [Description("类别节点")]
            [PropertyOrder(-183)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public CategoryNodeAppearanceObject CategoryNode
            {
                get
                {
                    if (this.categoryNode == null)
                        this.categoryNode = new CategoryNodeAppearanceObject(this.owner, this);
                    return this.categoryNode;
                }
            }

            private ContentNodeAppearanceObject contentNode;
            /// <summary>
            /// 内容节点
            /// </summary>
            [Description("内容节点")]
            [PropertyOrder(-180)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public ContentNodeAppearanceObject ContentNode
            {
                get
                {
                    if (this.contentNode == null)
                        this.contentNode = new ContentNodeAppearanceObject(this.owner, this);
                    return this.contentNode;
                }
            }

            private ScrollBarAppearanceObject scrollBar;
            /// <summary>
            /// 滚动条
            /// </summary>
            [Description("滚动条")]
            [PropertyOrder(-176)]
            [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
            [SkinProperty(true, false)]
            public ScrollBarAppearanceObject ScrollBar
            {
                get
                {
                    if (this.scrollBar == null)
                        this.scrollBar = new ScrollBarAppearanceObject(this.owner, this);
                    return this.scrollBar;
                }
            }

            #endregion

            public class CategoryNodeAppearanceObject : AppearanceObjectBase
            {
                internal CategoryNodeAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinSplitterLineColor = Color.Empty;
                private readonly Color defaultSplitterLineColor = SystemColors.GradientInactiveCaption;
                private Color splitterLineColor = Color.Empty;
                /// <summary>
                /// 分割线颜色
                /// </summary>
                [Description(" 分割线颜色")]
                [PropertyOrder(-196)]
                [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
                [SkinProperty(true, false)]
                public Color SplitterLineColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinSplitterLineColor;
                        }

                        if (this.splitterLineColor != Color.Empty)
                        {
                            return this.splitterLineColor;
                        }

                        return this.defaultSplitterLineColor;
                    }
                    set
                    {
                        if (this.splitterLineColor == value)
                            return;

                        this.splitterLineColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeSplitterLineColor()
                {
                    return this.splitterLineColor != Color.Empty;
                }
                private void ResetSplitterLineColor()
                {
                    this.splitterLineColor = Color.Empty;
                    this.Invalidate();
                }

                private ItemAppearanceObject normal;
                /// <summary>
                /// 正常状态
                /// </summary>
                [Description("正常状态")]
                [PropertyOrder(-194)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Normal
                {
                    get
                    {
                        if (this.normal == null)
                            this.normal = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.Window, SystemColors.Window);
                        return this.normal;
                    }
                }

                private ItemAppearanceObject enter;
                /// <summary>
                /// 鼠标进入状态
                /// </summary>
                [Description("鼠标进入状态")]
                [PropertyOrder(-192)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Enter
                {
                    get
                    {
                        if (this.enter == null)
                            this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.Window, SystemColors.Window);
                        return this.enter;
                    }
                }

                #endregion

                public class ItemAppearanceObject : AppearanceObjectBase
                {
                    internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color backColor, Color textColor, Color foldColor) : base(owner, parent)
                    {
                        this.defaultBackColor = backColor;
                        this.defaultTextColor = textColor;
                        this.defaultFoldColor = foldColor;
                    }

                    #region 属性

                    private Color skinBackColor = Color.Empty;
                    private readonly Color defaultBackColor = Color.Empty;
                    private Color backColor = Color.Empty;
                    /// <summary>
                    /// 背景颜色
                    /// </summary>
                    [Description("背景颜色")]
                    [PropertyOrder(-158)]
                    [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
                    [SkinProperty(true, false)]
                    public Color BackColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinBackColor;
                            }

                            if (this.backColor != Color.Empty)
                            {
                                return this.backColor;
                            }

                            return this.defaultBackColor;
                        }
                        set
                        {

                            if (this.backColor == value)
                                return;

                            this.backColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeBackColor()
                    {
                        return this.backColor != Color.Empty;
                    }
                    private void ResetBackColor()
                    {
                        this.backColor = Color.Empty;
                        this.Invalidate();
                    }

                    private Color skinTextColor = Color.Empty;
                    private readonly Color defaultTextColor = Color.Empty;
                    private Color textColor = Color.Empty;
                    /// <summary>
                    /// 文本颜色
                    /// </summary>
                    [Description("文本颜色")]
                    [PropertyOrder(-157)]
                    [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
                    [SkinProperty(true, false)]
                    public Color TextColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinTextColor;
                            }

                            if (this.textColor != Color.Empty)
                            {
                                return this.textColor;
                            }

                            return this.defaultTextColor;
                        }
                        set
                        {
                            if (this.textColor == value)
                                return;

                            this.textColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeTextColor()
                    {
                        return this.textColor != Color.Empty;
                    }
                    private void ResetTextColor()
                    {
                        this.textColor = Color.Empty;
                        this.Invalidate();
                    }

                    private Color skinFoldColor = Color.Empty;
                    private Color defaultFoldColor = Color.Empty;
                    private Color foldColor = Color.Empty;
                    /// <summary>
                    /// 折叠图标颜色
                    /// </summary>
                    [Description("折叠图标颜色")]
                    [PropertyOrder(-155)]
                    [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
                    [SkinProperty(true, false)]
                    public Color FoldColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinFoldColor;
                            }

                            if (this.foldColor != Color.Empty)
                            {
                                return this.foldColor;
                            }

                            return this.defaultFoldColor;
                        }
                        set
                        {
                            if (this.foldColor == value)
                                return;

                            this.foldColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeFoldColor()
                    {
                        return this.foldColor != Color.Empty;
                    }
                    private void ResetFoldColor()
                    {
                        this.foldColor = Color.Empty;
                        this.Invalidate();
                    }

                    #endregion

                }

            }

            public class ContentNodeAppearanceObject : AppearanceObjectBase
            {
                internal ContentNodeAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinSplitterLineColor = Color.Empty;
                private readonly Color defaultSplitterLineColor = Color.Empty;
                private Color splitterLineColor = Color.Empty;
                /// <summary>
                /// 分割线颜色
                /// </summary>
                [Description(" 分割线颜色")]
                [PropertyOrder(-196)]
                [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
                [SkinProperty(true, false)]
                public Color SplitterLineColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinSplitterLineColor;
                        }

                        if (this.splitterLineColor != Color.Empty)
                        {
                            return this.splitterLineColor;
                        }

                        return this.defaultSplitterLineColor;
                    }
                    set
                    {
                        if (this.splitterLineColor == value)
                            return;

                        this.splitterLineColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeSplitterLineColor()
                {
                    return this.splitterLineColor != Color.Empty;
                }
                private void ResetSplitterLineColor()
                {
                    this.splitterLineColor = Color.Empty;
                    this.Invalidate();
                }

                private ItemAppearanceObject normal;
                /// <summary>
                /// 正常状态
                /// </summary>
                [Description("正常状态")]
                [PropertyOrder(-194)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Normal
                {
                    get
                    {
                        if (this.normal == null)
                            this.normal = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.Window);
                        return this.normal;
                    }
                }

                private ItemAppearanceObject enter;
                /// <summary>
                /// 鼠标进入状态
                /// </summary>
                [Description("鼠标进入状态")]
                [PropertyOrder(-192)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Enter
                {
                    get
                    {
                        if (this.enter == null)
                            this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.ActiveCaption, SystemColors.Window);
                        return this.enter;
                    }
                }

                private ItemAppearanceObject selected;
                /// <summary>
                /// 已选中状态
                /// </summary>
                [Description("已选中状态")]
                [PropertyOrder(-190)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Selected
                {
                    get
                    {
                        if (this.selected == null)
                            this.selected = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.Window);
                        return this.selected;
                    }
                }

                #endregion

                public class ItemAppearanceObject : AppearanceObjectBase
                {
                    internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color backColor, Color textColor) : base(owner, parent)
                    {
                        this.defaultBackColor = backColor;
                        this.defaultTextColor = textColor;
                    }

                    #region 属性

                    private Color skinBackColor = Color.Empty;
                    private readonly Color defaultBackColor = Color.Empty;
                    private Color backColor = Color.Empty;
                    /// <summary>
                    /// 背景颜色
                    /// </summary>
                    [Description("背景颜色")]
                    [PropertyOrder(-158)]
                    [SkinProperty(true, false)]
                    public Color BackColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinBackColor;
                            }

                            if (this.backColor != Color.Empty)
                            {
                                return this.backColor;
                            }

                            return this.defaultBackColor;
                        }
                        set
                        {
                            if (this.backColor == value)
                                return;

                            this.backColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeBackColor()
                    {
                        return this.backColor != Color.Empty;
                    }
                    private void ResetBackColor()
                    {
                        this.backColor = Color.Empty;
                        this.Invalidate();
                    }

                    private Color skinTextColor = Color.Empty;
                    private readonly Color defaultTextColor = Color.Empty;
                    private Color textColor = Color.Empty;
                    /// <summary>
                    /// 文本颜色
                    /// </summary>
                    [Description("文本颜色")]
                    [PropertyOrder(-157)]
                    [SkinProperty(true, false)]
                    public Color TextColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinTextColor;
                            }

                            if (this.textColor != Color.Empty)
                            {
                                return this.textColor;
                            }

                            return this.defaultTextColor;
                        }
                        set
                        {
                            if (this.textColor == value)
                                return;

                            this.textColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeTextColor()
                    {
                        return this.textColor != Color.Empty;
                    }
                    private void ResetTextColor()
                    {
                        this.textColor = Color.Empty;
                        this.Invalidate();
                    }

                    #endregion

                }

            }

            public class LabelNodeAppearanceObject : AppearanceObjectBase
            {
                internal LabelNodeAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private Color skinSplitterLineColor = Color.Empty;
                private readonly Color defaultSplitterLineColor = Color.Empty;
                private Color splitterLineColor = Color.Empty;
                /// <summary>
                /// 分割线颜色
                /// </summary>
                [Description(" 分割线颜色")]
                [PropertyOrder(-196)]
                [Editor(typeof(AlphaColorEditor), typeof(UITypeEditor))]
                [SkinProperty(true, false)]
                public Color SplitterLineColor
                {
                    get
                    {
                        if (this.owner.GetSkinObjectSkinStateCore())
                        {
                            return this.skinSplitterLineColor;
                        }

                        if (this.splitterLineColor != Color.Empty)
                        {
                            return this.splitterLineColor;
                        }

                        return this.defaultSplitterLineColor;
                    }
                    set
                    {
                        if (this.splitterLineColor == value)
                            return;

                        this.splitterLineColor = value;
                        this.Invalidate();
                    }
                }
                private bool ShouldSerializeSplitterLineColor()
                {
                    return this.splitterLineColor != Color.Empty;
                }
                private void ResetSplitterLineColor()
                {
                    this.splitterLineColor = Color.Empty;
                    this.Invalidate();
                }

                private ItemAppearanceObject normal;
                /// <summary>
                /// 正常状态
                /// </summary>
                [Description("正常状态")]
                [PropertyOrder(-194)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Normal
                {
                    get
                    {
                        if (this.normal == null)
                            this.normal = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.Window);
                        return this.normal;
                    }
                }

                private ItemAppearanceObject enter;
                /// <summary>
                /// 鼠标进入状态
                /// </summary>
                [Description("鼠标进入状态")]
                [PropertyOrder(-192)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Enter
                {
                    get
                    {
                        if (this.enter == null)
                            this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.GradientActiveCaption, SystemColors.Window);
                        return this.enter;
                    }
                }

                #endregion

                public class ItemAppearanceObject : AppearanceObjectBase
                {
                    internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color backColor, Color textColor) : base(owner, parent)
                    {
                        this.defaultBackColor = backColor;
                        this.defaultTextColor = textColor;
                    }

                    #region 属性

                    private Color skinBackColor = Color.Empty;
                    private readonly Color defaultBackColor = Color.Empty;
                    private Color backColor = Color.Empty;
                    /// <summary>
                    /// 背景颜色
                    /// </summary>
                    [Description("背景颜色")]
                    [PropertyOrder(-158)]
                    [SkinProperty(true, false)]
                    public Color BackColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinBackColor;
                            }

                            if (this.backColor != Color.Empty)
                            {
                                return this.backColor;
                            }

                            return this.defaultBackColor;
                        }
                        set
                        {
                            if (this.backColor == value)
                                return;

                            this.backColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeBackColor()
                    {
                        return this.backColor != Color.Empty;
                    }
                    private void ResetBackColor()
                    {
                        this.backColor = Color.Empty;
                        this.Invalidate();
                    }

                    private Color skinTextColor = Color.Empty;
                    private readonly Color defaultTextColor = Color.Empty;
                    private Color textColor = Color.Empty;
                    /// <summary>
                    /// 文本颜色
                    /// </summary>
                    [Description("文本颜色")]
                    [PropertyOrder(-157)]
                    [SkinProperty(true, false)]
                    public Color TextColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinTextColor;
                            }

                            if (this.textColor != Color.Empty)
                            {
                                return this.textColor;
                            }

                            return this.defaultTextColor;
                        }
                        set
                        {
                            if (this.textColor == value)
                                return;

                            this.textColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeTextColor()
                    {
                        return this.textColor != Color.Empty;
                    }
                    private void ResetTextColor()
                    {
                        this.textColor = Color.Empty;
                        this.Invalidate();
                    }

                    #endregion

                }

            }

            public class ScrollBarAppearanceObject : AppearanceObjectBase
            {
                internal ScrollBarAppearanceObject(ISkinObject owner, AppearanceObjectBase parent) : base(owner, parent) { }

                #region 属性

                private ItemAppearanceObject normal;
                /// <summary>
                /// 正常状态
                /// </summary>
                [Description("正常状态")]
                [PropertyOrder(-194)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Normal
                {
                    get
                    {
                        if (this.normal == null)
                            this.normal = new ItemAppearanceObject(this.owner, this, SystemColors.ScrollBar, SystemColors.WindowFrame);
                        return this.normal;
                    }
                }

                private ItemAppearanceObject enter;
                /// <summary>
                /// 鼠标进入状态
                /// </summary>
                [Description("鼠标进入状态")]
                [PropertyOrder(-192)]
                [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
                [SkinProperty(true, false)]
                public ItemAppearanceObject Enter
                {
                    get
                    {
                        if (this.enter == null)
                            this.enter = new ItemAppearanceObject(this.owner, this, SystemColors.ScrollBar, SystemColors.WindowFrame);
                        return this.enter;
                    }
                }

                #endregion

                public class ItemAppearanceObject : AppearanceObjectBase
                {
                    internal ItemAppearanceObject(ISkinObject owner, AppearanceObjectBase parent, Color trackBackColor, Color thumbBackColor) : base(owner, parent)
                    {
                        this.defaultTrackBackColor = trackBackColor;
                        this.defaultThumbBackColor = thumbBackColor;
                    }

                    #region 属性

                    private Color skinTrackBackColor = Color.Empty;
                    private readonly Color defaultTrackBackColor = Color.Empty;
                    private Color trackBackColor = Color.Empty;
                    /// <summary>
                    /// 轨道背景颜色
                    /// </summary>
                    [Description("轨道背景颜色")]
                    [PropertyOrder(-139)]
                    [SkinProperty(true, false)]
                    public Color TrackBackColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinTrackBackColor;
                            }

                            if (this.trackBackColor != Color.Empty)
                            {
                                return this.trackBackColor;
                            }

                            return this.defaultTrackBackColor;
                        }
                        set
                        {
                            if (this.trackBackColor == value)
                                return;

                            this.trackBackColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeTrackBackColor()
                    {
                        return this.trackBackColor != Color.Empty;
                    }
                    private void ResetTrackBackColor()
                    {
                        this.trackBackColor = Color.Empty;
                        this.Invalidate();
                    }

                    private Color skinThumbBackColor = Color.Empty;
                    private readonly Color defaultThumbBackColor = Color.Empty;
                    private Color thumbBackColor = Color.Empty;
                    /// <summary>
                    /// 拇指背景颜色
                    /// </summary>
                    [Description("拇指背景颜色")]
                    [PropertyOrder(-134)]
                    [SkinProperty(true, false)]
                    public Color ThumbBackColor
                    {
                        get
                        {
                            if (this.owner.GetSkinObjectSkinStateCore())
                            {
                                return this.skinThumbBackColor;
                            }

                            if (this.thumbBackColor != Color.Empty)
                            {
                                return this.thumbBackColor;
                            }

                            return this.defaultThumbBackColor;
                        }
                        set
                        {
                            if (this.thumbBackColor == value)
                                return;

                            this.thumbBackColor = value;
                            this.Invalidate();
                        }
                    }
                    private bool ShouldSerializeThumbBackColor()
                    {
                        return this.thumbBackColor != Color.Empty;
                    }
                    private void ResetThumbBackColor()
                    {
                        this.thumbBackColor = Color.Empty;
                        this.Invalidate();
                    }

                    #endregion

                }

            }

        }

        #endregion

    }
}
